Posting credit to a bank account uri - balanced-payments

If I already have the bank account token (id returned by balanced.js), do I need to do a get to credit the account?
The documentation at:
https://docs.balancedpayments.com/current/api.html?language=php#credit-an-existing-bank-account
says: To credit an existing bank account, you simply pass the amount to the nested credit endpoint of a bank account. The credits_uri is a convenient uri provided so that you can simply issue a POST with the amount and a credit shall be created.
But the example given below it, does a get on bank account first and then a credit.
How do I post to the credits_uri with the amount and other parameters without first doing a get?

If you don't want to get a GET first, you would need to store the credits_uri of the bank account in question and then POST directly to that. e.g.
$credit = new \Balanced\Credit(array(
"uri" => "/v1/bank_accounts/BA123123/credits", // the credits_uri from the bank account
"amount" => 100
))->save();

Related

AuthorizeNET CIM Payments

I have moved Authorize.NET AIM to CIM. I have two questions to solve:
In Authorize.NET live account I can see two transaction for one transaction one is 0$ voided transaction and other one is real transaction, can I avoid 0$ transaction or it is for what?
$email_address = 'user' . time() . '#domain.com';
$description = 'Monthly Membership No. ' . md5(uniqid(rand(), true));
$customer_id = substr(md5(uniqid(rand(), true)), 16, 16);
// Create the profile
$cim->setParameter('email', $email_address);
$cim->setParameter('description', $description);
$cim->setParameter('merchantCustomerId', $customer_id);
$cim->createCustomerProfile();
In the above code can we sent customer real email instead of generated email?
will it be a compliance issue?
The $0 transaction is to verify the credit card is valid before creating the customer payment profile. No, you cannot stop it from happening and you want this to occur as it allows you to get immediate feedback if a payment profile is invalid. That way you can react to it immediately rather then waiting for their first payment to fail.
Yes, you can, and should, send the correct customer email. That random email is just an example to show you how it works. The same goes for the $description and $customer_id fields as well.

How can I use Stripe to delay charging a customer until a physical item is shipped?

I'm in the process of building an online marketplace which sells shippable goods. The site will be similar to Etsy, which will connect merchants with buyers.
I'd like to be able to charge a customer's card ONLY when an item is shipped by a merchant to avoid chargebacks and provide an Amazon-like payment experience. This will also help us avoid chargebacks and payment disputes in case a merchant is slow to ship or flakes out. In some cases, the goods will take more than 7 days to be custom manufactured and shipped out
Here's an example timeline:
1/1/2014 - Customer adds $75 worth of items to their cart and clicks "buy". Enters credit card info.
1/1/2014 - Customer's card is verified and a $75 temporary hold is placed on their card. Order is sent to merchant for fulfillment.
1/14/2014 - Merchant ships goods to customer and adds shipping tracking info
1/14/2014 - Customer's card is charged for the full amount and merchant receives $75 minus fees.
I plan to use Stripe Connect for payment processing, but am not sure how to delay capturing a payment for more than 7 days. Any thoughts? I don't want to aggregate the funds under my own account and use payouts since this will likely run afoul of money transmission laws. Any help would be appreciated!
EDIT: It looks like Quora has a similar question here , but the answers don't seem to deal with the case where a merchant ships out the item but the payment fails.
After further research, it seems there's no way to delay capturing a charge past the 7 day authorization window.
But here's one way to delay a charge:
Tokenize a credit card using the stripe.js library
Create a new stripe customer passing in the token as the "card" param
An example from the Stripe FAQ: https://support.stripe.com/questions/can-i-save-a-card-and-charge-it-later
Note that the longer you wait between tokenizing a card and actually charging it, the more likely your charge will be declined for various reasons (expired card, lack of funds, fraud, etc). This also adds a layer of complexity (and lost sales) since you'll need to ask a buyer to resubmit payment info.
I'd still like to confirm that a certain amount can be charged (like a "preauthorization"), but this lets me at least charge the card at a later date.
Celery has built a service to help you do this with Stripe. They are very easy to use, but note that they charge 2% per transaction.
actually you can save user token and pay later with tracking info
# get the credit card details submitted by the form or app
token = params[:stripeToken]
# create a Customer
customer = Stripe::Customer.create(
card: token,
description: 'description for payinguser#example.com',
email: 'payinguser#example.com'
)
# charge the Customer instead of the card
Stripe::Charge.create(
amount: 1000, # in cents
currency: 'usd',
customer: customer.id
)
# save the customer ID in your database so you can use it later
save_stripe_customer_id(user, customer.id)
# later
customer_id = get_stripe_customer_id(user)
Stripe::Charge.create(
amount: 1500, # $15.00 this time
currency: 'usd',
customer: customer_id
)
Stripe release a delay method to place a hold without charging. https://stripe.com/docs/payments/capture-later
<?php
require_once('stripe-php/init.php');
\Stripe\Stripe::setApiKey('your stripe key');
$token = $_POST['stripeToken'];
$stripeinfo = \Stripe\Token::retrieve($token);
$email = $stripeinfo->email;
$customer = \Stripe\Customer::create(array(
"source" => $token,
"email" => $email)
);
?>

Payment using credit card through balanced payment in rails step by step

I am new to use balanced payments.
After get credit card info what is first, second... all steps..
can any one give me step by step so i can do on that way.
Thanks in advance
The steps would depend on what type of application you're trying to develop.
The basis of the system is that you create a Customer for each of your users. balanced.js removes the need for you to be PCI compliant because the sensitive data is submitted directly to Balanced and never goes through your servers. You use balanced.js to tokenize credit cards and bank accounts and add them to specific Customer instances. Once you've got the cards and bank accounts added you can do things like debit customerBuyerA and credit customerSellerB.
Next, I encourage you to read through some of the common fee scenarios to get an idea of what's going to work well for your business. https://docs.balancedpayments.com/current/#collecting-your-fees
Both https://docs.balancedpayments.com/current/overview.html and https://docs.balancedpayments.com/current/api.html have plenty of information to get you going from there.
I encourage you to stop by #balanced on IRC to get any other development questions answered.
I solved using below code in test mode (in RUBY):
Install gem "balanced"
Assign API key
Balanced.configure('API KEY')
Accept user card info
card = Balanced::Card.new( :card_number => "4111111111111111",
:expiration_month => "12",
:expiration_year => "2020"
).save
Create buyer to debit fee
buyer = Balanced::Marketplace.my_marketplace.create_buyer(:card_uri => card.uri)
5 Debit from buyer account
`another_debit = buyer.debit(
:amount => 1000,
:appears_on_statement_as => "MARKETPLACE.COM"
)`
7 Credit to Merchant account (You need to verify Bank account first from here)
merchant = Balanced::Account.find('/v1/marketplaces/TEST-MP6wn7oEW117Yn9gKXuQaTIO/bank_accounts/BANK ACC ID')
merchant.credit('1000')
Hope work for any one and suggestion welcome.

Balanced duplicate bank account detection

I've create a new merchant account on Balanced via the API. I added a bank account to this account and then tokenized the exact same bank account and then added that again. I was expecting the second association to throw a 409 telling me that the account could not be added.
I have two questions:
Why does the API allow me to add the exact same bank account / card to an account twice?
How can I detect this and not add the bank account / card to the account?
Here is the example of two bank accounts I've created on an account via the Ruby gem:
irb(main):029:0> #bank_accounts.items.each { |a|
puts "#{a["bank_name"]} #{a["bank_code"]} created-#{a["created_at"]} #{a["last_four"]} uri=#{a["uri"]} id=#{a["id"]}"
}; nil
123456789 created-2012-07-11T23:36:57.290555Z 2333 uri=/v1/marketplaces/TEST-MP4Z4RaRDF6TWqeupiVUSu8m/accounts/AC2tip2eDhi92THXXEkIdys1/bank_accounts/BA2mP9GtEPVB3v9DzWJ7ZH8B id=BA2mP9GtEPVB3v9DzWJ7ZH8B
123456789 created-2012-07-11T23:37:22.655007Z 2333 uri=/v1/marketplaces/TEST-MP4Z4RaRDF6TWqeupiVUSu8m/accounts/AC2tip2eDhi92THXXEkIdys1/bank_accounts/BA2PlMIVFyMSSzo2zzUZb2XA id=BA2PlMIVFyMSSzo2zzUZb2XA
=> nil
There is no constraint on adding duplicate bank accounts and cards as you note. This was a decision made to allow the developer to lessen the burden of writing code for catching duplicate bank accounts. Your feedback is noted and appreciated.
You can index the cards or bank accounts associated with a user, Balanced does not return the full card number but by comparing the last_four, expiration, and name you can tell if a card is a match, similar fields are available for bank accounts but swap expiration with bank_code (routing number).
The code to do something like this in Ruby would be:
require 'balanced'
Balanced.configure 'e1c5ad38d1c711e1b36c026ba7e239a9'
# duplicate cards
card1 = Balanced::Card.new(:card_number=>"4111111111111111", :expiration_month=>"12", :expiration_year=>"2020").save() # original card
card2 = Balanced::Card.new(:card_number=>"4111111111111111", :expiration_month=>"12", :expiration_year=>"2020").save() # our duplicate card
card3 = Balanced::Card.new(:card_number=>"4111111111111111", :expiration_month=>"12", :expiration_year=>"2021").save() # a different card
# create a new account
buyer = Balanced::Account.new(:email_address => '%d#example.org' % Time.now).save()
buyer.add_card(card1.uri)
# helper function
def has_card(cards, card)
cards.map { |c| c.last_four == card.last_four && c.expiration_month == card.expiration_month && c.expiration_year == card.expiration_year }.include? true
end
puts 'buyer already has this card' if has_card(buyer.cards, card2)
puts 'buyer does not have this card' if not has_card(buyer.cards, card3)

What do the n and m stand for in the PayPal API variables like L_PAYMENTREQUEST_n_NAMEm

Try as I might, I can't seem to find what the n and m stand for in the api variable request format above. I'm guessing m stands for different items, but not sure what n stands for.
'n' is the number of your payment request. If you have one payment request going on at a time, this will be 0. If you have multiple (if you want to use parallel payments, for example), it would be 0 for the first payment request, 1 for the second, et cetera.
'm' is the specific product within that payment request.
E.g.
// First payment request
PAYMENTREQUEST_0_SELLERPAYPALACCOUNTID=test#example.com
PAYMENTREQUEST_0_AMT=10
L_PAYMENTREQUEST_0_NAME0=Test+product
// Second payment request
PAYMENTREQUEST_1_SELLERPAYPALACCOUNTID=test#anotherexample.com // Recipient of this payment request
PAYMENTREQUEST_1_AMT=5 // Total of all products combined in this payment request
L_PAYMENTREQUEST_1_NAME0=Test+product+2 // Name of the first product/item in this payment request
L_PAYMENTREQUEST_1_AMT0=2.50 // Price of this one product
L_PAYMENTREQUEST_1_NAME1=Test+product+3 // Name of the second product/item in this payment request
L_PAYMENTREQUEST_1_AMT1=2.50 // Price of this one product
Source: https://cms.paypal.com/us/cgi-bin/?cmd=_render-content&content_ID=developer/e_howto_api_ECParallelPaymens