PHP: Stripe connect API would not accept card details? - php

I know that asking this here could be throwing a stone in the dark because I found 2 other similar questions but none had any answers to it.
Any way, I hope someone has already found the solution for this and can shed a light on it.
Let me explain the scenario first as it might help with finding a solution:
I am creating stripe custom connect accounts like this:
$acct = \Stripe\Account::create(array(
"country" => "US",
"type" => "custom",
"email" => "email#mail.com"
));
Then I add Bank Accounts to them like so:
$account->external_accounts->create(
array(
'external_account' => array(
"object" => "bank_account",
"country" => "US",
"currency" => "usd",
"account_holder_name" => 'Jane Austen',
"account_holder_type" => 'individual',
"routing_number" => "111000025",
"account_number" => "000123456789"
)
));
This all works fine so far....
Now, what I need to do is to be able to transfer Money/Payments from the connected custom accounts into their Bank accounts.
For that purpose, I will need to add a Credit Card to that connetced account so that card details can be used for making payments into the Bank Accounts.
So I went ahead and tried this:
$account->external_accounts->create(
array(
'external_account' => array(
"object" => "card",
"exp_month" => 8,
"exp_year" => 2018,
"number" => "4012888888881881",
"currency" => "usd",
"cvc" => "123"
)
));
And that did NOT work and gave me this error:
Requests made on behalf of a connected account must use card tokens from Stripe.js, but card details were directly provided.
So I changed my strategy and tried this:
$result = \Stripe\Token::create(
array(
"card" => array(
"name" => "Some Name",
"exp_month" => 8,
"exp_year" => 2018,
"number" => "4012888888881881",
"currency" => "usd",
"cvc" => "123"
)
));
$token = $result['id'];
$account->external_accounts->create(
array(
'external_account' => array(
"object" => "card",
"source" => "".$token.""
)
));
However, this gave me the same error message!!!
This is very frustrating because if you look at their own API documentation, you will clearly see that they say:
source required
Either a token, like the ones returned by Stripe.js, or a dictionary containing a user's credit card details (with the options shown below). Stripe will automatically validate the card.
This can be seen here:
https://stripe.com/docs/api#create_card
Could someone please advice on this issue?
I cannot use stripe.js in my project so I will need to use the API.
Any help would be greatly appreciated.
Thanks in advance.
First Edit:
Here is a strange one.. I generated a Stripe card token from here:
https://codepen.io/fmartingr/pen/pGfhy
Note that the above codepen uses the stripe.js to generate the tokens....
and tried to use the token from there in my PHP code like so:
$account->external_accounts->create(
array(
'external_account' => array(
"object" => "card",
"source" => "tok_1AqPXeDQzcw33c71uncYBFdm"
)
));
but this gives me the exact same error:
Requests made on behalf of a connected account must use card tokens from Stripe.js, but card details were directly provided.

Please use this it will add your external account
$result = \Stripe\Token::create(
array(
"card" => array(
"name" => "Some Name",
"exp_month" => 8,
"exp_year" => 2018,
"number" => "4012888888881881",
"currency" => "usd",
"cvc" => "123"
)
));
$token = $result['id'];
$account->external_accounts->create(
array(
'external_account' => "".$token.""
));

Related

Is there any method in brain-tree auto renew payment?

HI I am using braintree(braintree/braintree_php": "4.5.0) . I have implemented the 3dsecure in the web.It working fine. I need to auto renew the payment with paymentMethodToken. Below code i have used for auto renewal.
$trans = [
'amount' => "14.63",
'merchantAccountId' => "Vo**ID",
'paymentMethodToken' =>"token",
'transactionSource' => "recurring",
'customFields' => [
'client_id' => "id",
'service_id' => "id",
'invoice_id' => "id",
'action' => "autorenew",
'slots' => "15",
],
'options' => [
'submitForSettlement' => true,
'storeInVaultOnSuccess' => true,
'paypal' => [
'description' =>"Renew server",
]
]
];
$transaction = $gateway->transaction()->sale($trans);
When run this code i get below error
Authorization in Util.php line 59:
The above code is working when the user enter the credit card information to pay.This only gives error when i do payment with paymentMethodToken to auto renew the payments.Any help?
reference : https://developers.braintreepayments.com/guides/paypal/server-side/php
As per I understood your requirement. You need to do auto payment.
For that, Braintree provide the best way to do this called Subscription.
Let me know, If you need any more help.

How to implement stripe SCA in PHP?

As per the stripe documentation here we read all the information and know the ideas about the SCA. But I am not getting any related API documentation. So, I am confusing how to implement in our existing PHP code and what are the parameters we will add. Please find below my example of code:
\Stripe\Stripe::setApiKey(API_KEY_HERE);
$customer = \Stripe\Token::create(
array("card" => array(
"name" => $arg['name'],
"number" => $arg['number'],
"exp_month" => $arg['exp_month'],
"exp_year" => $arg['exp_year'],
"cvc" => $arg['cvc']
))
);
/* some other code here */
$charge = \Stripe\Charge::create(
array(
"amount" => $arg['amount'],
"currency" => "usd",
"description" => "Subscription Charge",
"customer" => $customer->id
)
);
/* some other db related code here */
I have shared the code. Could you please let us know what we need to change for SCA?
I just answered this question where OP did a great job on the question.
Perhaps her code can help you see how you need to implement this using JS in the
front-end and PHP in the backend.
Stripe - Payment Intents (3d secure issue)

WePay API response error "payment method does not exist or does not belong to app"

i was having a problem with Wepay API. My codes are correct but it keeps on returning an error saying "payment method does not exist or does not belong to app". I already configured the permission to allow tokenized credit cards. But still. Any feedback is greatly appreciated. Thanks!
Here is my code
require_once('public/payment/wepay/wepay.php');
$user = API::get_client(['fldClientEmail' => $email])->first();
// change to useProduction for live environments
\Wepay::useStaging(WEPAY_CLIENT_ID, WEPAY_CLIENT_SECRET);
$wepay = new \WePay($user->fldClientWepayTokenAccess);
// $wepay = new \WePay(WEPAY_ACCESS_TOKEN);
// dd($email);die;
// dd($user->fldClientWepayAccountID);die;
// charge the credit card
$response = $wepay->request('checkout/create', [
'account_id' => $user->fldClientWepayAccountID,
'amount' => number_format(Input::get('amount_tipped'),2),
'currency' => 'USD',
'short_description' => 'A short description',
'type' => 'goods',
'payment_method' => array(
'type' => 'credit_card',
'credit_card' => array(
'id' => Input::get('cc_id')
)
)
]);
// display the response
return $response;
Make sure that when you follow the tutorial from their docs, you replace all of the credentials from the examples. I was using their Javascript library for the tokenization of the credit card with the client_id they provided.
response = WePay.credit_card.create({
"client_id": YOUR.CLIENT.ID.HERE,
"user_name": valueById('name'),
"email": valueById('email'),
"cc_number": valueById('cc-number'),
"cvv": valueById('cc-cvv'),
"expiration_month": valueById('cc-month'),
"expiration_year": valueById('cc-year'),
"address": {
"postal_code": valueById('postal_code')
}
If you don't provide your own, is like you were creating those credit cards for another application that's not yours.
If this didn't do the trick, check this article, hopefully it does:
https://support.wepay.com/hc/en-us/articles/203609273-WePay-API-Error-Codes

DocuSign REST API (PHP) - pre-fill custom tags

I am working on project in which I need to use DocuSign API (PHP). This is my first experience with DocuSign and I successfully made template in DocuSign Console with roleName = signer. There I also made Custom Text Tags: address, city, state and phone and drag them to the desired location in my template. I want there to put my customer (signer) information from project database.
From my project I successfully made connection with DocuSign via PHP API and receive Embedded Singing View URL which opens my template where the user can sign document without problem.
But... all my custom text tags are empty and signer can type into them. I need to pre-fill them with signer personal data which is coming from database. I triple check custom tag label spelling, upper/lower case in my DocuSign Console and in my code as well as roleName->tagLabel relation. My PHP code is below.
Can someone, please, tell me what I am doing wrong?
I lost two days on it.
$data = array(
"accountId" => $accountId,
"emailSubject" => $this->_emailSubject,
"templateId" => $templateId,
"templateRoles" => array(
array(
"email" => $email,
"name" => $recipientName,
"clientUserId" => $clientUserId,
"roleName" => "signer",
"customFields" => array(
"textCustomFields" => array (
array (
"name" => "address",
"value" => "Address from DB",
"show" => "true",
),
array (
"name" => "city",
"value" => "City from DB",
"show" => "true",
),
array (
"name" => "state",
"value" => "State from DB",
"show" => "true",
),
array (
"name" => "phone",
"value" => "Phone from DB",
"show" => "true",
),
),
),
),
),
"status" => "sent"
);
You need to use the textTabs type in your JSON, not customFields which is used for something else. For instance, if you drag a Data Field from the UI onto the document and give it name address, to pre-fill that field you would need to reference it's tabLabel and value fields like this:
"roleName" => "signer",
"tabs" => array(
"textTabs" => array(
array(
"tabLabel"=> "address",
"value" => "123 Main St."
)
)
)

Braintree API in PHP success and currency issue

My braintree integration is going well - there's just two minor issues.
Firstly what is the option name to pass through and specify a currency code e.g.:
$options = [
"amount" => "10.00"
"creditCard" => [
"number" => "",
"cvv" => "",
"expirationMonth" => "",
"expirationYear" => ""
],
"currencyCode" => "AUD" // This is what im after?
];
Secondly, when I run the code below I get this: "Undefined property: Braintree_Result_Successful::$_attributes" when running the check on success?
$result = Braintree_Transaction::sale($this->collect_data());
if($result->success) { // do something }
I work at Braintree. If you have more questions, please feel free to get in touch with our support team.
To use a different currency, you specify a different merchant account:
$result = Braintree_Transaction::sale(array(
'amount' => '100.00',
'merchantAccountId' => 'gbp_merchant_account',
'creditCard' => array(
'number' => '5105105105105100',
'expirationDate' => '05/12'
)
));
Contact Braintree to get the additional merchant accounts set up.
For your second question, I've not seen that error before. Your best bet is to contact Braintree support so they can help you with the problem.

Categories