Transfer money from stripe account to other account - ios

I'm using this to charge a connected account the send the money to another account but I keep getting this error message.
I keep getting this error message:
You cannot supply a destination when charging a connected account.
return stripe.charges.create({
amount: 1000,
currency: "usd",
source: customer_id,
destination: {
account: "acct_1BxnsfGGXo2wovzm"
},
});
How can I do it? Thanks

Looking at the error message it seems the api believes you're using account debits where the destination parameter does not make sense:
https://stripe.com/docs/connect/account-debits
So it's likely that your customer_id variable contains an account id instead of a customer id here.

Related

How to integrate SCA Stripe Checkout with Stripe Connect using Rails 5

I've been trying to enable payments to users (sellers in this case) on my site. I've managed to allow the seller to set up their own Stripe account, and then their Stripe account ID is saved in the database.
However, I can't manage to allow people to pay the sellers. I've been looking at the Stripe docs and although very detailed, I can't figure out where everything is meant to go. I would like something like this:
I have got a new charge view, and this code is supposed to be in it I think:
// Initialize Stripe.js with the same connected account ID used when creating
// the Checkout Session.
var stripe = Stripe('pk_test_CscsJfPdlaNBpLla09y0aA6W', {
stripeAccount: '{{CONNECTED_STRIPE_ACCOUNT_ID}}'
});
stripe.redirectToCheckout({
// Make the id field from the Checkout Session creation API response
// available to this file, so you can provide it as parameter here
// instead of the {{CHECKOUT_SESSION_ID}} placeholder.
sessionId: '{{CHECKOUT_SESSION_ID}}'
}).then(function (result) {
// If `redirectToCheckout` fails due to a browser or network
// error, display the localized error message to your customer
// using `result.error.message`.
});
I've also got a Charges Controller, but I'm not sure if this is meant to be there:
session = Stripe::Checkout::Session.create({
payment_method_types: ['card'],
line_items: [{
name: "Cucumber from Roger's Farm",
amount: 200,
currency: 'gbp',
quantity: 10,
}],
payment_intent_data: {
application_fee_amount: 200,
},
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/cancel',
}, {stripe_account: '{{CONNECTED_STRIPE_ACCOUNT_ID}}'})
How do I Initialize Stripe.js with the right account ID? Where is this code meant to be? Do I need more?
Any help would be massively appreciated. Thanks.

Payment via Braintree PayPal always fails iOS

I have opened a ticket about this on Braintree iOS's GITHub. Just hoping to get some help fast. Here goes the issue:
As the title says, my payment (in iOS) always fails. While apparently, the payment in my colleague's work (Android) succeeds.
I followed thoroughly the sample codes and guidelines from here: https://developers.braintreepayments.com/guides/paypal/client-side/ios/v4
In iOS, after all the process (Client Token from our Server --> BT SDK --> PayPal browser --> App --> send nonce to our server), the error I get from our server is always:
PayPal pending payments are not supported.
My backend guy does not know the reason behind this too, he only showed and gave me this log:
{
"errors": {},
"params": {
"transaction": {
"type": "sale",
"amount": "1",
"merchantAccountId": "USD",
"paymentMethodNonce": "80823f63-5ea9-0b8b-67da-0710bd7d9ff1",
"orderId": "333",
"descriptor": {
"name": "company name*myurl.com"
},
"options": {
"submitForSettlement": "true",
"paypal": {
"customField": "custom",
"description": "description"
}
}
}
},
"message": "Unknown or expired payment_method_nonce.",
"creditCardVerification": null,
"transaction": null,
"subscription": null,
"merchantAccount": null,
"verification": null
}
And here's what I do in setting up my SDK:
private func processPayPalClientToken(_ clientToken: String) {
SVProgressHUD.show(withStatus: "Please wait...")
self.braintreeClient = BTAPIClient(authorization: clientToken)
let payPalDriver = BTPayPalDriver(apiClient: self.braintreeClient)
payPalDriver.viewControllerPresentingDelegate = self
payPalDriver.appSwitchDelegate = self
let request = BTPayPalRequest(amount: self.bookingViewModel.getTotalAmount())
payPalDriver.requestOneTimePayment(request) { (nonce, error) in
SVProgressHUD.dismiss(completion: {
if let error = error {
self.showAlert(title: "title...", message: "Error: \(error.localizedDescription).", okayButtonTitle: "OK") { _ in }
return
}
guard let nonce = nonce else { return }
self.processNonceToServer(nonce)
})
}
}
So... any idea what's the reason behind this? Thanks!
EDIT: Additional info that I found a while ago. The SFSafari browser dismisses itself too soon that's why the nonce I get is always invalid. Why is that?
Full disclosure: I work at Braintree. If you have any further questions, feel free to contact
support.
Based on the payment method nonce that you posted in your question, I was able to take a look into our server-side logs to see what the issue is.
Without giving away any specific API Credentials, it appears as if the server responsible for generating a client token in your setup is passing a different Sandbox merchant ID than the server responsible for creating the transaction with that payment method nonce, which is leading to an error.
Your server is responsible for generating a client token, which contains the authorization and configuration details that your client needs to initialize the client SDK. When a payment method nonce is created, it is tied to the merchant ID that is specified in the client token authorization. The merchant ID passed during the Transaction Sale call or other API Calls must match the merchant ID that is tied to that specific payment method nonce, so you will need to fix this discrepancy in your backend code.
For the benefits of the others who are experiencing the same issue, check out my closed ticket I filed on Braintree's Github (link above or this: https://github.com/braintree/braintree_ios/issues/405)
Here's my colleague and I have discovered:
We can pay successfully using this CREDIT UNION payment method.
BUT we can't pay using PAYPAL BALANCE.
The errors like below happens in PayPal Balance option.
PayPal pending payments are not supported
So the answer in this issue would be: make sure that everything in your client is working and you're using correct and same accounts for the clientToken and the PayPal account you're using to pay.

Check if twitter account has been deactivated?

I'm using the twitter4j API and I want to see if, given the ID of a user's account, if that account has been deactivated.
You need to use users/show. It will give you an error code if the user has been suspended.
For example
https://api.twitter.com/1.1/users/show.json?screen_name=nero
Returns
{
"errors": [
{
"code": 63,
"message": "User has been suspended."
}
]
}
If you only have the ID, you can make a similar call - https://api.twitter.com/1.1/users/show.json?user_id=.....
With Twitter4J you use showUser and pass it either the string of the username, or the int of the user ID.
As far as I know there is no dedicated method to do this but using users/lookup (in your case this method) with the user ids you are getting back the the active users only. So if some id is missing from the response those users are the suspended ones.

Is there any alternative for Reference Transaction in Paypal REST API?

After some time of researching and exploring the Paypal REST API documentation, I've found that currently reference transaction is available only in Paypal Classic API but not in Paypal REST API as stated in this StackOverflow post so I'm trying to find an alternative to bill users with different amounts every month.
Integrated Paypal REST API in my Rails 4 application. I'm trying to create agreements with auto-billing plans without charging real amount, and I planned to use set-balance to charge the remaining amounts and bill the users with outstanding amount. Eventually I've searched through the methods in paypal-sdk-rest but there's no method for me to set an outstanding balance on the agreement object.
And now I'm in stuck. Is there a Ruby method call to set and bill the outstanding balance to the agreements, or perhaps another way of charging users with different amounts every month?
A way I'd think of is to send invoices to users manually by using the Invoice object in REST API, but I prefer to bill users using agreements instead. Using Classic API might be the best option in this case but REST is still a better choice for future.
Hope to get reference transaction works in REST API very soon.
Plan:
plan = Paypal::Plan.new({
name: "Test Plan",
description: "Test recurring plan",
type: "infinite",
payment_definitions: [{
name:"Free Trial",
type:"TRIAL",
frequency:"MONTH",
frequency_interval:"1",
amount: {
value: "0.00",
currency: "USD"
},
cycles: "1"
},
{
name:"Standard Package",
type:"REGULAR",
frequency:"MONTH",
frequency_interval:"1",
amount: {
value: "0.01",
currency: "USD"
},
cycles: "11"
}],
merchant_preferences: {
setup_fee: {
value: "0",
currency: "USD"
},
auto_bill_amount: "YES",
return_url: return_url,
cancel_url: cancel_url,
}
})
Agreement:
agreement = Paypal::Agreement.new({
name: "Monthly billing",
description: "Billing Agreement",
start_date: (Date.today+ 1.month).strftime("%Y-%m-%dT%H:%M:%SZ"),
payer: {
payment_method: "paypal",
},
plan: {
id: Settings.plan_id
}})

Paypal recurring payments with variable amount 2 (in Spain)

some days ago, I wrote this post regarding Paypal recurring payments with variable amount Paypal recurring payments with variable amount
I marked it as fixed, however it is not.
First, I decided to develop approach 1 (by removing old profile and creating a new one). This worked. But, after that I realized, that I didn´t cover all my requirements. So finally, the right approach for me is number 2. This means, as #Andrew Angell suggested, I will develop a custom billing system that bills the customers. For that, I will create Billing Agreements and I will use the returned ids to execute Reference transactions with the amount I need and whenever I need. So far, it´s right?
According to Paypal docs, this is possible: https://developer.paypal.com/docs/classic/express-checkout/integration-guide/ECReferenceTxns/
So, I´m trying to follow the steps, so first a execute a setExpressCheckout:
# Paypal setExpressCheckout
def setExpressCheckout(billingType, returnURL, cancelURL, price, description)
#api = PayPal::SDK::Merchant::API.new
if billingType == "credit-card"
billingType = "Billing"
else
billingType = "Login"
end
#set_express_checkout = #api.build_set_express_checkout({
SetExpressCheckoutRequestDetails: {
ReturnURL: returnURL,
CancelURL: cancelURL,
LocaleCode: "US",
LandingPage: billingType,
PaymentDetails: [{
NotifyURL: returnURL,
OrderTotal: {
currencyID: "EUR",
value: price
},
ShippingTotal: {
currencyID: "EUR",
value: "0"
},
TaxTotal: {
currencyID: "EUR",
value: "0"
},
PaymentDetailsItem: [{
Name: description,
Quantity: 1,
Amount: {
currencyID: "EUR",
value: price
},
}],
PaymentAction: "Authorization" # To authorize and retain the funds, and when booking is confirmed capture them.
}],
BillingAgreementDetails: [{
BillingType: "MerchantInitiatedBillingSingleAgreement",
BillingAgreementDescription: description
}]
}
})
# Make API call & get response
#express_checkout_response = #api.set_express_checkout(#set_express_checkout)
# Access Response
if #express_checkout_response.success?
#token = #express_checkout_response.Token
puts "setExpressCheckout completed OK :)"
#paypal_url = #api.express_checkout_url(#express_checkout_response)
else
puts "setExpressCheckout KO :("
#express_checkout_response.Errors
puts "#express_checkout_response=" + #express_checkout_response.inspect
end
#express_checkout_response
end
However, I get this error:
#LongMessage="Merchant not enabled for reference transactions", #ErrorCode="11452"
It´s quite clear, just need to contact Paypal support guys and ask them to enable Reference transactions in my Paypal sandbox account. Right? I already did it and I´m just waiting.
However, what really worries me, is that I called Paypal support and they told me that this approach will not work in Spain. Although it´s in the doc, it´s only working in UK. Is this true?
If it´s true, I´m really in a trouble, because as far as I know, Paypal doesn´t not support subscriptions with variable amount.
Paypal technical support guy has enabled my sandbox account to reference transactions. I have developed the logic and it´s working. At least, in Sandbox and in Spain.
So, I will assume, it works.
Bad the Paypal guy on the phone that told me it wasn´t possible.

Resources