I am currently trying to setup a user experience to enable the user to put down banking information to be stored as a recipient in order to transfer funds to account they set up.
Here is the issue:
When user sends in information, Stripe creates a token and that, using ajax is sent over to a .PHP file which handles the creation of the recipient account. But on the creation of the recipient I get a 500 Error:
POST /functions/stripeAcc/makeCustomer.php 500 (Internal Server Error) jquery-latest.min.js:2
send - jquery-latest.min.js:2
p.extend.ajax - jquery-latest.min.js:2
stripeResponseHandler
e.ajaxJSONP.success js.stripe.com/:1
window.(anonymous function) js.stripe.com/:1
(anonymous function) tokens:1
Here is the PHP file:
...
$email = $_POST['email'];
$name = $_POST['cardholderfullname'];
$token = $_POST['token'];
require_once('./stripe-php/lib/Stripe.php');
Stripe::setApiKey("mykey");
$recipient = Stripe_Recipient::create(array(
"name" => $name,
"type" => "individual",
"bank_account" => $token,
"email" => $email)
);
... This is where the 500 happens
Now after I check my logs inside the logs on my Stripe Account I notice a call being placed with a 200 status (this mean everything worked) except a recipient did not get made, so that is confusing right there.
Log file:
Summary
Time:
2013/07/13 20:09:45
Method:
POST
URL:
/v1/tokens
Status:
200
IP address:
71.239.53.232
Parsed Request Query Parameters
bank_account:
country: "US"
routing_number: "110000000"
account_number: "********6789"
key: "myKey"
callback: "sjsonp1373746168110"
_method: "POST"
Response body
id: btok_2BxFI1xYXF8ECd
livemode: false
created: 1373746185
used: false
object: "token"
type: "bank_account"
bank_account:
object: "bank_account"
bank_name: "STRIPE TEST BANK"
last4: "6789"
country: "US"
validated: false
fingerprint: "wC1v8BWXZe7MyW3n"
I am using the test credentials for the Account number and Routing number:
Routing numbers
Number Type
110000000 STRIPE TEST BANK US routing number
Account numbers
Number Type
000123456789 Successful US account number
I am sure some of you were stumped but I figured it out:
The issue was that, they updated the version of the API and my version did not have the recipient file within the API on my server. Crazy right? You would think they would notify you or something.
Thanks for the help.
Related
I'm trying to use the Twilio API to buy a phone number with a "Local" address requirement on behalf of a customer using the "Connect" API.
The purchase request looks like this:
$twilio = new \Twilio\Rest\Client($customerConnectedSid, env('TWILIO_AUTH_TOKEN'));
$numberRes = $twilio->incomingPhoneNumbers->create([
'phoneNumber' => $numberString,
'addressSid' => $user->company->twilio_address_sid,
]);
The error I get back from Twilio is:
[HTTP 400] Unable to create record: Could not find Address with sid AD*** for account AC*** to satisfy Local Address requirement
I don't know why it can't "find" that address because both the accountSid and sid match in the response from:
$twilio->addresses->read([], 100)
So clearly the address exists.
I think I just figured it out, but I'm going to leave the question up anyway in case someone else encounters it.
The error message is just bad.
It can "find" the address, but it doesn't satisfy the local address requirement.
Make sure the address is actually for the region where the phone number is.
I made a personnal plugin for use Stripe on my website. I have 2 questions.
First, i have this error when verifCertSsl is to true :
"error setting certificate verify locations: CAfile: CApath: /etc/ssl/certs". My website is using OVH eand HTTPS connection.
I don't know why i have this error. When the method verifCertSsl is to false everything works, but there is no data security.
And the second question, how can i pass client datas to stripe like first name, last name, email, adress. I have this :
var form = document.getElementById('payment-form');
//add owne info
var ownerInfo = {
amount: document.querySelector('#amount'),
currency: 'eur',
owner: {
nom: document.querySelector('#name'),
prenom: document.querySelector('#prenom'),
adresse: document.querySelector('#adresse'),
zip: document.querySelector('#zip'),
ville: document.querySelector('#ville'),
email: document.querySelector('#email')
},
};
form.addEventListener('submit', function(event) {
event.preventDefault();
stripe.createToken(card, ownerInfo).then(function(result) {
if (result.error) {
// Inform the user if there was an error
var errorElement = document.getElementById('card-errors');
errorElement.textContent = result.error.message;
} else {
// Send the source to your server
stripeTokenHandler(result.token);
}
});
});
but i retrieve nothing.
After a successful payment i don't receive email, while i use "receipt_email" :
\Stripe\Stripe::setApiKey($secret_key);
$charge = \Stripe\Charge::create(array(
'amount' => $amount, // $10
'currency' => 'eur',
'card' => $token,
//"customer" => "cus_AFGbOSiITuJVDs",
//"source" => "src_18eYalAHEMiOZZp1l9ZTjSU0",
'receipt_email' => $email,
)
);
for information i use wordpress
Thanks everyone
First, i have this error when verifCertSsl is to true : "error setting certificate verify locations: CAfile: CApath: /etc/ssl/certs". My website is using OVH eand HTTPS connection. I don't know why i have this error. When the method verifCertSsl is to false everything works, but there is no data security.
A common cause for this error is that the data/ca-certificates.crt file is not included in your PHP installation, or it has file permissions that is preventing your code from accessing it. Once you have done this, you should be fine (and the SSL handshake between your server and our API should work fine).
And the second question, how can i pass client datas to stripe like
first name, last name, email, adress.
The issue here is that you are not passing the address information properly to the API. Stripe's API has specific names for each property or parameter and those are also in English. To pass the address information on tokenization your code would look like this:
var options = {
name: document.getElementById('name').value,
address_line1: document.getElementById('address-line1').value,
address_line2: document.getElementById('address-line2').value,
address_city: document.getElementById('address-city').value,
address_state: document.getElementById('address-state').value,
address_zip: document.getElementById('address-zip').value,
address_country: document.getElementById('address-country').value,
};
stripe.createToken(card, options).then(setOutcome);
You can see a basic example here: https://jsfiddle.net/4o5msan0/
After a successful payment i don't receive email, while i use "receipt_email" :
I think the issue here is that you are not passing receipt_email properly and the $email variable might be empty. You need to make sure that you have retrieved this value from the browser which means your form needs to post it explicitly. It won't be retrieve from the token. If you do, then remember that Stripe does not send email receipts in Test mode, only in Live mode.
I am trying to send an (simple test) email when I receive an account.updated call for a custom account from Stripe API. My other webhooks to create charges and inform customers about successful or failed charges work like this, but here I get an error 500 (I can see that in the dashboard of the custom account) and the mail is NOT send, so I am not sure what I am doing wrong here. My code looks like this:
<?php
require_once('vendor/autoload.php');
// Set your secret key: remember to change this to your live secret key in production
// See your keys here: https://dashboard.stripe.com/account/apikeys
\Stripe\Stripe::setApiKey("sk_test_XXXX");
// Retrieve the request's body and parse it as JSON
$input = #file_get_contents("php://input");
$event_json = json_decode($input);
// Verify the event by fetching it from Stripe
$event = \Stripe\Event::retrieve($event_json->id);
// Do something with $event
if ($event->type == 'account.updated') {
// The E-Mail message to send to inform about a succeeded charge
$message = 'test';
// Send the E-Mail
mail('test#example.com', 'We need more info about you!', $message);
}
http_response_code(200); // PHP 5.4 or greater
Thank you for your help!
If you look at your web server's error.log (usually accessible from your hosting control panel or in /var/log/) do you see more detail on what's causing the 500?
Could it be $event = \Stripe\Event::retrieve($event_json->id); failing?
If the event is occurring directly on a connected account, you may also need to pass the account id to retrieve it.
See here for a bit more context,
https://stripe.com/docs/connect/webhooks
The code would be more like:
$event = \Stripe\Event::retrieve(
array("id" => $event_json->id),
array("stripe_account" => $event_json->account));
https://stripe.com/docs/connect/authentication#authentication-via-the-stripe-account-header
I'm getting an Authorization Failed response from 2Checkout when using OmniPay API.
I had successfully hooked up Stripe with OmniPay, so then I went about hooking up 2Checkout. When you go to do that, the initial package on Github warns you to get the newer version from a user collizo4sky. So, I did, and then got it to work slightly without fatal error.
In my web form, I generate a token properly and the sandbox logs at 2Checkout confirm this. I then use this code in OmniPay to attempt to charge the card:
use Omnipay\Omnipay;
$sMerchantTransID = rand(11111111,99999999);
$oGateway = Omnipay::create('TwoCheckoutPlus_Token');
$oGateway->setPrivateKey($config->TWOCHECKOUT_PRIVATE_KEY);
$oGateway->setAccountNumber($config->TWOCHECKOUT_SELLERID);
$oGateway->setTestMode(true);
$oResponse = $oGateway->purchase(array(
'amount' => $sPrice,
'currency' => 'USD',
'token' => $sToken,
'transactionId' => $sMerchantTransID
))->send();
if (!$oResponse->isSuccessful()) {
die('ERROR: ' . $oResponse->getMessage());
}
However, the message comes back with "Authorization Failed". So, I went into the source code of the OmniPay API for collizo4sky's package in this path...
omnipay/vendor/collizo4sky/omnipay-2checkout/src/Message/TokenPurchaseRequest.php
...and added some log file debugging of the sendData() class method. This is what it responded with, and note that I changed some of the values for obvious privacy reasons:
array (
'sellerId' => '901414261',
'privateKey' => 'EAEC8615-4C48-4D98-B7E5-4B6D8865E1BA',
'merchantOrderId' => 65639323,
'token' => 'FDI1ZTM3N2UtY2VkZS00NTM1LWE5MTctYzI4MjA5YWI4Yjhm',
'currency' => 'USD',
'total' => '519.00',
)
Yes, the sellerID and the privateKey came from the sandbox account, as did the publishable key when I generated the token in the web form in the first place.
So, anyway, when this is submitted to the sandbox URL, it returns with this response:
HTTP/1.1 400 Bad Request
Server: Apache-Coyote/1.1
Cache-Control: no-cache, no-store, must-revalidate
Date: Fri, 22 Apr 2016 03:30:37 GMT
Expires: 0
Pragma: no-cache
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
{"validationErrors":null,"response":null,"exception":{"errorMsg":"Authorization Failed","httpStatus":"400","exception":false,"errorCode":"600"}}
What am I doing wrong?
EDIT:
I then tried using the 2Checkout-supported PHP library that they provide. I did the exact same transaction and it too returns "Authorization Failed".
I'm wondering if it's a setting on my account even though I'm using a sandbox? I mean, I have not yet been approved in production, and was trying to get the sandbox going until then so that I could do a demo.
I also regenerated API keys in the sandbox and tried again, and that failed.
The credit card I used was the one they provide on the sandbox under the sandbox API keys, and I used a CVV of 123 with 12/18 as the expiration date. I then thought maybe it wanted a 4 digit year, so I updated that and tried again, and that failed too with the same consistent error of "Authorization Failed".
When I check on what "Authorization Failed" means, it appears that it's the credit card that's the problem.
My gut feeling so far is telling me that I'm doing everything correct and that it's a flag on my account that's the issue. I mean, if my regular account is not yet approved, will the sandbox still work?
The only way that I could get a transaction to go through was to set the Demo mode to "Off" manually in the sandbox settings under Account > Site Management, and then to pass in at least a billing address. I'd love to find out how to not have the billing address requirement (such as for digital download goods), but have not found a way to do so just yet, or if that's even possible.
Please note that if you set Demo Mode to "On", plus don't send a billing address, the transaction will go through okay but then it won't appear as a sale under the Sales tab. That's not very useful, because when you go live you want an actual sale that you can refund, and Demo Mode doesn't simulate an actual charge, merely an authorization of that card. (At least that's what I've figured out.)
On the transactionId parameter, I took a shortcut for purposes here. Please make it a unique number in your system (like some number generated with UNIX time) or you could end up with a potential collision.
I also tried commenting out just the email, or just the phone, or both, and that didn't work -- you'll get "Parameter Error". Then, I tried sending in only these fields under card: billingName, email, billingPostcode, and billingCountry -- and that failed with "Parameter Error" too. So then I added billingState -- "Parameter Error". Then, added billingCity -- "Parameter Error". So, in order for the transaction to go through, unless someone can show me some setting override or technique, the Billing Address is required, and must also include email and phone, to my wild surprise. That's a showstopper for some people, I'm sure, such as those trying to sell non-tangibles like digital downloads. Note also that I tried the official 2Checkout-created PHP API and tried all these tests again with that, and again, received "Parameter Error" unless the full billing address (including email and phone too) was utilized. This full billing address requirement with also email and billing phone is going to be a bummer for some businesses, I'm sure.
EDIT: This answer, if I'm guessing right, is an official answer from someone working at 2Checkout, itself? It sure does look that way. Anyway, he says that the billing address is definitely required because, as he states, "This is a requirement of our banking partners for address verification."
EDIT2: You'll need to experiment with a real live transaction, but I discovered in at least sandbox mode that, if I pass an empty string for the phoneNumber field on the official 2Checkout PHP library, or the billingPhone in the OmniPay API, then the transaction goes through okay. They just want to see that parameter, although it can be empty. But don't take my word for it -- test it on a live transaction (and refund yourself) to reconfirm, as I was only doing this in the sandbox. This answer seems to officially confirm from 2Checkout itself that they allow this.
Fixed code:
use Omnipay\Omnipay;
$sMerchantTransID = rand(11111111,99999999);
$oGateway = Omnipay::create('TwoCheckoutPlus_Token');
$oGateway->setPrivateKey($config->TWOCHECKOUT_PRIVATE_KEY);
$oGateway->setAccountNumber($config->TWOCHECKOUT_SELLERID);
$oGateway->setTestMode(true); // turns on Sandbox access
$oResponse = $oGateway->purchase(array(
'amount' => $sPrice,
'currency' => 'USD',
'token' => $sToken,
'transactionId' => $sMerchantTransID,
'card' => array(
'billingName' => $sName,
'billingAddress1' => $sStreet1,
'billingAddress2' => $sStreet2,
'billingCity' => $sCity,
'billingState' => $sState,
'billingPostcode' => $sZip,
'billingCountry' => $sCountry,
'email' => $sEmail,
'billingPhone' => $sPhone
)
))->send();
if (!$oResponse->isSuccessful()) {
die('ERROR: ' . $oResponse->getMessage());
}
We have an application which is calling the Trustpilot API to send out invitation e-mails to customers so that they can review their recent orders.
Creating the review link etc. works correctly. However, when calling the final step to actually send out the invitation e-mail, the "status" field of the response is always "notsent" and the e-mail is not sent.
The URL is https://invitations-api.trustpilot.com/v1/private/business-units/business_unit_id/invitations
The JSON response is as follows:
{
id: "<response id>",
businessUnitId: "<business unit id>",
businessUserId: "<business user id>",
recipient: {
name: "<recipient name>",
email: "<recipient email>"
},
referenceId: "<order id>",
templateId: "<default en-GB template code>",
locale: "en-GB",
sender: {
email: "noreply.invitations#trustpilot.com",
name: "<client name>"
},
replyTo: "noreply.invitations#trustpilot.com",
createdTime: "2015-04-29T14:34:40.176727Z",
preferredSendTime: "2015-04-29T14:34:40.176727Z",
sentTime: null,
tags: [ ],
redirectUri: "<trustpilot review url>",
status: "notsent",
source: "Kickstart"
}
We have not modified the SPF record for the client's domain, so I am using noreply.invitations#trustpilot.com as the sender and reply-to addresses. Additionally, I have set the preferred send time so that the e-mail should be sent straight away. Nothing I do is making any difference.
Can anyone advise what I might be doing wrong?
Figured this out - the reply to address I was specifying was being rejected. Even though it was valid (or when I tried using noreply.invitations...) - I switched to using one that the client has been using themselves and they started sending straight away after that.
The reply-to address should be one of the pre-configured addresses in your B2B account. You can see here: https://support.trustpilot.com/hc/en-us/articles/201841237-Sender-Information