Square - How to get ApplicationID using OAuth for Payment Form - oauth

Can someone help me to understand how make Payment Form works for merchants?
I am working on ECommerce site where merchants can sell their products. To use Square as payment provider I used OAuth to retrieve access token (which works fine).
To take payment I use Payment Form (to get card nonce). On Payment Form init I need to send ApplicationID & LocationId. I'am able to get last one but not the first one param.
If I try to use my own ApplicationID I get the error on Transactions/Charge
{
"errors":[{
"category":"INVALID_REQUEST_ERROR",
"code":"NOT_FOUND",
"detail":"Card nonce not found in this `sandbox` application environment. Please ensure an application ID belonging to the same environment is used for the SqPaymentForm."
}]
}

This error happens when you use a combination of sandbox application Ids and production application Ids. I'm guessing that you are using your correct application id, and attempting to charge with your sandbox access token.
If you want to take a sandbox payment with the payment form, use your sandbox application id, it should look like sandbox-sq0idp-XXXXXXXXXXXXXXXXXXX

Each merchant must use their own credentials to load locations. You must send the merchant locationId selected and their access_token to do the charge in its account.
Carlos

Related

No such token "some_random_token" found Stripe error in rails

I am using stripe in my app.
There is a function in in app which is used to create charge from card to company account registered in our site.
It usually works fine and all payments are completed but sometimes it says no such token found.
I am creating token just before creating charge and code is something like that:
token = Stripe:Token:Create({
customer: stripe_customer_id
}, company_stripe_secret_key).id
#please ignore the syntax or any error as it works fine and I am writing it on mobile
#purpose of code it to tell you that how follow works
And just after that I am creating charge and when charge request goes it returns no such token "token_returned_by_stripe"
How is it possible? Stripe is returning the token and I am using that token and it says no such token....???
Your code snippet there is cloning a Token from the Platform, on to the Connect account. You are most likely creating a Direct Charge (on the Connect account) after that code snippet.
There are a few reasons you would be getting this error, for example you could be cloning the Token on acct_1 but creating the Charge on acct_2, or not cloning at all but trying to use the Platform Token directly on a Connect account, etc.
But really it boils down to that your code has a Token on one account but is trying to use it on a different account. You should troubleshoot and debug your code by adding logs to see which Tokens are being created and on which account you try to create the Charge.

No such customer error in stripe

I am using stripe component in my application,when I tested with sk_test_1XXXXXX all payments were success,now I changed that key to another sk_test_2XXX,when iam trying to pay through this,getting an error "No such custome -cus_xxxxxxxxxxx".How to resolve this.
You created that customer with your 1st test key. These customers will be invisible (as well as any cards, subscriptions, etc) to your second test key.
Once you changed / moved key you'll need to recreate these test customers, they are not shared between test keys and accounts.
Your customer does not exist. Try login into the stripe dashboard and seeing if that customer exists.

Stripe Error - Known test bank accounts cannot be used in live mode. Payout Set up for rails app

I'm trying to setup the payout process for the merchants on my site, but for some reason when I use Stripe Test bank details I get with the error of "Known test bank accounts cannot be used in live mode". I'm using the development client ID for testing obviously, so not sure why am I end up with this error. :( Any ideas would be very welcome! Thanks.
The activation form expects real information about a real business. This means that even if you're testing, you might want to create a real account with real details and that's what Stripe asks for here.
Since you're only testing the OAuth flow and don't want to activate your account you should ignore the form entirely. When testing with your Development client id ca_XXXXX there should be a link at the top of the form called "Skip this account form". This links lets you bypass the activation form (which would be required in production) and finish the connection with the platform.

How to use Stripe Connect in an iOS app

Has anyone had success using Stripe connect with an iOS app. I have a few questions:
I'm following the guidelines here: https://stripe.com/docs/connect/getting-started
Registering an Application: easy, no problem here
Then a little further down:
Send your users to Stripe: again, easy no problem here, I just have a button that opens up the link in a UIWebView. I assume having the client_id in the URL is fine? A lot of my uncertainty is what IDs/keys I should hard-code into the app
Then a little further down:
After the user connects or creates a Stripe account, we'll redirect them back to the redirect_uri you set in yourapplication settings with a code parameter or an error.
What I'm doing here is using the UIWebview's webView:shouldStartLoadWithReqest:navigationType delegate method to check for the string "code=" in the URL. If it finds that, then I'm able to grab the "code" parameter. So in reality, the redirect_uri is completely unnecessary for me. Is this the right way to handle this? Should I be doing this within my app or on my server?
After receiving the code, we are supposed to make a POST call to receive an access_token. Again, should this be done within the app or on the Server? It requires the use of a secret_key, so I'm guessing server? And how do I send credit card information along with this token if the token needs to be sent to the server? I know how to obtain the card number, exp date, and CVV. But in terms of passing it to the server (with or without the token) is something I'm not sure of.
Then when it comes to actually writing PHP, Ruby, or Python code on the server, I'm at a total loss.
Any help would be greatly appreciated.
You should setup a small web app to create stripe charges and storing you customers Authorization Code. Configure two routes in your web app for redirect_uri and webhook_uri and add the url in your Stripe Apps settings. The charges should be created from a server side app because it requires the secret_key / authorization_code which should not be stored in an iPad app. Otherwise they may lead to a security leak. I'm trying to describe the concept below:
Provide the stripe connect button in your app and set the link to open in Safari (not in an web view). You should add a state parameter to the url with an id which is unique to your users.
On tapping the button your user will be redirected to Stripe where s/he will be asked to authorize your application. Upon authorization stripe will hit your redirect_uri with a authorization_code and the state you previously provided. Do a post call according to Stripe Documentation with the authorization_code to get an access_token. Store the access_token mapped with the state in a database.
Define a custom url scheme in your app. Invoke the custom url from your web app. The user supposed to open the url in mobile safari. So invoking the custom url will reopen your application. You can pass an additional parameter to indicate failure / success. In your app update the view based on this parameter.
Now you are all set to create a charge on your server on behalf of the iPad user. Use stripe iOS sdk to generate a card_token from the card information. It'll require your stripe publishable_key. Then define an api in your web app which takes 3 parameters: card_token, user_id and amount. Call this api from your iPad app whenever you want to create a charge. You can also encrypt this information with a key if you're worried about security using any standard encryption method. You can easily decrypt the info in your web app as you know the key.
When this api is called from the iPad app you'll receive the user_id (which you saved as state previously), card_token and amount. Retrieve the access_token mapped to the user_id (or state). You can then made a charge on behalf of the user using the access_token, card_token and amount.
You can use ruby / php / python / node in the server as Stripe provides sdk for them. I assume other languages can be used as well as there is a REST interface.
Please note that this is just a concept. It should work like it but I haven't implemented it yet. I'll update this answer with sample code when I'm done.
You can use UIWebView. You will still need to use redirect urls and monitor the redirect using the delegate "webView:shouldStartLoadWithRequest:navigationType:"

PayPal Sandbox - CreateBillingAgreement call returns Internal Error (10001)

I'd appreciate any help with this, I've run around in circles trying all sorts of combinations with the PayPal Api - but I'm hitting a brick wall on this one.
I'm looking to call the CreateBillingAgreement method but each time I do it fails and reports a 10001 'internal error' from paypal in the response.
I have a valid token and I'm using version 84.0. I've successfully called SetupExpressCheckout and DoExpressCheckout, both of which succeed and the payment goes through. I'm setting up a future payment / pre-authorisation on the SetupExpressCheckout and the user agrees to that no problems.
​Do I need to change settings on the merchant in the sandbox? Am I calling things in the wrong order maybe? (SetExpress, GetExpress, DoExpress, CreateBilling)?
​I'm looking to use this billing agreement to allow a reference transaction in the future. I'm having a test account 'pay' using paypal and not forwarding any credit card details, the payment is for a digital service with no delivery (no shipping is set, no addresses or delivery costs are involved). The overall goal is to provide a one-click re-order button, whereby no details need to be entered by the customer.
I'm using the C# api in asp.net 4, or more specifically I've created Service References from the paypal sandbox wsdl and I'm using those in asp.net.
​Any and all help is appreciated - thanks.
​Russell.
You don't need to call CreateBillingAgreement if you're specifying billingtype MerchantInitiatedBilling in your SetExpressCheckout and DoExpressCheckoutPayment API call. CreateBillingAgreement is only necessary if you don't want to call DoExpressCheckoutPayment.
If MerchantInitiatedBilling is set, DoExpressCheckoutPayment will already return a billing agreement ID, which you can use in DoReferenceTransaction.
I don't have access to an example at hand, but will update this post as soon as I've found one for you.

Resources