I am using this library to verify PayPal users through email ID. The API I am using is GetVerifiedStatus. The developer of the library provides an email address in the code and it works fine. The code returns the status as "VERIFIED" for his email ID.
However, whenever I try to use my email ID, it shows "Cannot determine PayPal Account status" with ErrorID --580023. I tried another person's email ID and still it does not work. I am sure there is no typo in the email, firstname, lastname fields.
Seems, these links addresses the same issue.
PayPal GetVerifiedStatus not working with other accounts and Does PayPal's GetVerifiedStatus `belong' to the api caller's country?
This is the code that comes with the library. (added my paypal email ID and name)
require_once('../includes/config.php');
require_once('../autoload.php');
// Create PayPal object.
$PayPalConfig = array(
'Sandbox' => $sandbox,
'DeveloperAccountEmail' => $developer_account_email,
'ApplicationID' => $application_id,
'DeviceID' => $device_id,
'IPAddress' => $_SERVER['REMOTE_ADDR'],
'APIUsername' => $api_username,
'APIPassword' => $api_password,
'APISignature' => $api_signature,
'APISubject' => $api_subject,
'PrintHeaders' => $print_headers,
'LogResults' => $log_results,
'LogPath' => $log_path,
);
$PayPal = new angelleye\PayPal\Adaptive($PayPalConfig);
// Prepare request arrays
$GetVerifiedStatusFields = array(
'EmailAddress' => 'xxxxxx', // Required. The email address of the PayPal account holder.
'FirstName' => 'xxxxxx', // The first name of the PayPal account holder. Required if MatchCriteria is NAME
'LastName' => 'xxxxxx', // The last name of the PayPal account holder. Required if MatchCriteria is NAME
'MatchCriteria' => 'NAME' // Required. The criteria must be matched in addition to EmailAddress. Currently, only NAME is supported. Values: NAME, NONE To use NONE you have to be granted advanced permissions
);
$PayPalRequestData = array('GetVerifiedStatusFields' => $GetVerifiedStatusFields);
// Pass data into class for processing with PayPal and load the response array into $PayPalResult
$PayPalResult = $PayPal->GetVerifiedStatus($PayPalRequestData);
// Write the contents of the response array to the screen for demo purposes.
echo '<pre />';
print_r($PayPalResult);
I am not getting any idea why it is happening. Can anyone help please?
You are testing in sandbox mode. You must create sandbox accounts, either via https://developer.paypal.com/docs/classic/lifecycle/sb_about-accounts/#create-and-manage-sandbox-accounts or using the standard user flow on https://www.sandbox.paypal.com/us/home .
Related
I'm running the stripe/stripe-php 6.43.0 API on Laravel 5.8 and everything works fine until I try to pull a customer's bank account as a source. Or any source, really.
Here's what I've got:
\Stripe\Stripe::setApiKey(env('STRIPE_SECRET'));
$token = \Stripe\Token::create([
'bank_account' => [
'country' => $request->country,
'currency' => $request->currency,
'account_holder_name' => $request->account_holder_name,
'account_holder_type' => $request->account_holder_type,
'routing_number' => $request->routing_number,
'account_number' => $request->account_number
]
])->__toArray(true);
//dd($token);
$bank_account = \Stripe\Customer::createSource(
\Auth::user()->company->stripe_id,
[
'source' => $token['id'],
]
);
$bank_array = $bank_account->__toArray(true);
//dd($bank_array);
$customer = \Stripe\Customer::retrieve(\Auth::user()->company->stripe_id);
//dd($customer);
$bank_account = $customer->sources()->retrieve(\Auth::user()->company->stripe_bank_id);
dd($bank_account);
Everything works fine until I get to $customer->sources()->retrieve, then it throws a Call to undefined method Stripe\Customer::sources() error. The company creates in the Stripe dashboard and the bank account is there also. I've also double and triple checked that the variables for the bank account ID and Stripe ID are being set in the API request.
I've also tried creating the customer & bank account without tokenizing (doesn't make a difference), and I've tried to find a source id so I can just \Stripe\Source::retrieve($src), but the API responses don't contain a source ID.
Any ideas?
I'm authenticating my users on my web service and then creating Firebase custom token via php-jwt:
// Requires: composer require firebase/php-jwt
use Firebase\JWT\JWT;
// Get your service account's email address and private key from the JSON key file
$service_account_email = ...;
$private_key = ...;
function create_custom_token($uid, $is_premium_account) {
global $service_account_email, $private_key;
$now_seconds = time();
$payload = array(
"iss" => $service_account_email,
"sub" => $service_account_email,
"aud" => "https://identitytoolkit.googleapis.com/google.identity.identitytoolkit.v1.IdentityToolkit",
"iat" => $now_seconds,
"exp" => $now_seconds+(60*60), // Maximum expiration time is one hour
"uid" => $uid,
"claims" => array(
"premium_account" => $is_premium_account
)
);
return JWT::encode($payload, $private_key, "RS256");
}
But the users that I authenticate this way, don't show the administrator-friendly "Identifier" and "Providers" fields in the "Authentication" panel in the Firebase Console:
The first two are users that I authenticated via this custom authentication process, and the last one is a user that I authenticated directly via Google.
How can I populate the "Identifier" and the "Providers" fields for users created via custom authentication?
The "Providers" column will only display an icon if the information attached to a user matches one or more of the the given providers in the "Sign-In Methods" section (https://console.firebase.google.com/project/_/authentication/providers).
Custom providers don't have a distinct icon, and Firebase wouldn't know what to display in the "Identifier" column (the UID is already in its own column at the end).
However, you do have some control for the display of the columns by creating them in advance (meaning: before signing them in for the first time), or by updating the user information after the user entry has been created.
I prepared an example showing which combination of fields leads to which display:
Please note:
The display name has no effect: if it is the only data provided, the user is considered anonymous.
Email + Password match the "Email/Password" Provider
Phone Numbers will alway match the "Phone" provider
The icons for a matched provider will be displayed in the column, even if a provider has been disabled.
Emails and Phone numbers have to be unique. If your application allows multiple users with the same email address/phone number, you will get into trouble, if you just want to see more information about the users of your Firebase project.
You can create and update users via the Firebase Auth REST API, but I would suggest to use one of the official Firebase Admin SDKs SDK to do it - in case you want to stick to PHP, I happen to know an unofficial one: kreait/firebase-php (Documentation) (Disclaimer: I'm the maintainer of the PHP SDK :) ).
On a non-technical note: I wouldn't bother too much with the user list in the Firebase Web Console: use the Firebase CLI tool or one of the official (or unofficial ;) ) Admin SDKs to create an overview that meets your needs.
You mentioned in the Bounty Annotation that you asked this in the Firebase Slack Community without an answer - you can find me and other PHP developers in the #php channel. I enabled notifications for the channel, so please feel free to join if you have further questions.
FYI, this is the code I wrote with the PHP SDK to create the data for the screenshot above:
<?php
declare(strict_types=1);
use Kreait\Firebase;
use Kreait\Firebase\Util\JSON;
require_once __DIR__.'/vendor/autoload.php';
$serviceAccount = Firebase\ServiceAccount::fromJsonFile(__DIR__.'/service_account.json');
$firebase = (new Firebase\Factory())
->withServiceAccount($serviceAccount)
->create();
$auth = $firebase->getAuth();
// Remove all users
foreach ($auth->listUsers() as $user) {
$auth->deleteUser($user->uid);
}
// Simulate custom auth
$ct = $auth->createCustomToken('a-custom-auth');
$r = $auth->getApiClient()->exchangeCustomTokenForIdAndRefreshToken($ct);
echo JSON::prettyPrint($auth->getUser('a-custom-auth'));
echo JSON::prettyPrint($auth->createUser([
'uid' => 'displayname-only',
'displayName' => 'Jérôme Gamez',
]));
echo JSON::prettyPrint($auth->createUser([
'uid' => 'email-only',
'email' => 'jerome#example.org',
]));
echo JSON::prettyPrint($auth->createUser([
'uid' => 'email-and-password',
'email' => 'jerome#example.com',
'password' => 'password'
]));
echo JSON::prettyPrint($auth->createUser([
'uid' => 'phone-only',
'phoneNumber' => '+49-123-1234567',
]));
echo JSON::prettyPrint($auth->createUser([
'uid' => 'email+name+phone',
'email' => 'jerome#example.net',
'displayName' => 'Jérôme Gamez',
'phoneNumber' => '+49-123-7654321',
]));
echo JSON::prettyPrint($auth->createUser([
'uid' => 'email+name+password+phone',
'email' => 'jerome#example.de',
'displayName' => 'Jérôme Gamez',
'password' => 'example123',
'phoneNumber' => '+49-321-7654321',
]));
I am currently implementing the Paypal Payment Gateway into my shop.
I added an return URL inside my paypal sandbox account.
Payment steps so far:
Create an order
Create a payment via WC_Gateway_Paypal class
Redirect to paypal site login & process payment
redirect to return_url on succes
Sample code:
function create_order()
{
$order = wc_create_order();
$product = wc_get_product(55);
$order->add_product($product, 1);
$address = array(
'first_name' => 'John',
'last_name' => 'Doe',
'company' => '',
'email' => 'john#doe.com',
'phone' => '111111',
'address_1' => '',
'address_2' => '',
'city' => '',
'state' => '',
'postcode' => '',
'country' => ''
);
$order->set_address($address, 'billing');
$order->set_address($address, 'shipping');
$order->calculate_totals();
$order->set_payment_method('paypal');
$paypal = new WC_Gateway_Paypal();
$paymentdetails = $paypal->process_payment($order->get_id());
return $paymentdetails;
}
In $paymentdetails I return the paypal URL where I redirect the customer to.
After successful payment the customer gets redirect from paypal to: http://mypage.com/56/?key=wc_order_59d24a26d4ccb&utm_nooverride=1
Now I want to update my order. I know that I could just read the ID and the key of the order from the redirect URL, but wouldnt that be an security issue? If someone knows the ID or the key he could just trigger a GET to my site and update his order without actual payment.
Is there a better way to accomplish this? Or do I just have to use the key=wc_order_59d24a26d4ccb instead of the ID and be careful not to send the key to the frontend?
Also, I am not getting any transaction_id, $order->get_transaction_id(); is empty after successful payment. Is this because I am developing on my local machine / with a sandbox account?
This is most likey because you are developing on a local machine.
The paypal integration does a lot of stuff in the background (exchanging tokens, updating orders, etc...). When you create a payment, paypal gets your local dev URL (i.e. http://localhost/something) but cannot reach it because you are behind a router. Try to move the installation to a server or webspace and try again, it should work.
I'm using MailChimp's API v3.0 and having problems when trying to update the subscriber's postal address.
The data I'm sending is:
[method] => patch
[path] => lists/123456789/members/membershash
[url] => https://us13.api.mailchimp.com/3.0/lists/123456789/members/membershash
[body] => {"merge_fields":{"FNAME":"firstname","LNAME":"lastname","TITLE":"Mr","BDAY":"10\/11","TSTATUS":"approved","ADDRESS":{"addr1":"10811 International Drive","city":"Rancho Cordova","state":"CA","zipcode":"95670"}}}
[timeout] => 10
[headers] => PATCH /3.0/lists/123456789/members/membershash HTTP/1.0
The error I'm getting is:
400: Your merge fields were invalid. Please enter a complete address.
I've tried sending it as a string (fields separated by double spaces as described in the import file schema), i.e.
10811 International Drive Rancho Cordova CA 95670
but I got the same error. What am I doing wrong?
Just in case you're still looking... I'm using the Drewm wrapper and updating mailing address by using the following:
$subscriber_hash = $MailChimp->subscriberHash($email);
$result = $MailChimp->patch("lists/$list_id/members/$subscriber_hash", [
'merge_fields' => [
'FNAME' => $firstname,
'LNAME' => $lastname,
'ADDRESS' => array
(
'addr1' => $addline1,
'addr2' => $addline2,
'city' => $city,
'state' => $state,
'zip' => $zip,
'country' => $country
)
],
'interests' => [$interest_id => true],
]);
print_r($result);
The "enter a complete address" error will happen if you do not send a value for country.
Both addr2 and country are optional, but MailChimp secretly requires you to send an empty string for country whereas you can leave out addr2 entirely.
MailChimp support told me this:
You are right that the only required parameters of the Address object
is addr1, city, state, and zip. That being said, for parity with
performance of the application, the "country" parameter would need to
be present and be given an empty string value. The empty string will
resolve to the default_country. Which if not changed is the US.
I understand that this is not completely consistent with the
documentation. I will pass along this feedback to our team that
oversees our schema as this can create confusion.
What if you have a foreign address? The country would be filled in, but many of them do not have values for the state and zip/postal code.
I can't get MailChimp to recognise any address in the UK and it's also not recognising a change in email, saying that the new email is already up when it's not
I am currently using the API to integrate Mailchimp with an existing form on my website.
I want to add subscribers to a group. My subscribers have STATUS - PENDING and I set the interests accordingly dependent on which group I want them subscribed to.
However, I found this neither added them to the group or sent out the confirmation email. When I take the interests section out, this works perfectly and sends out a confirmation email to the subscriber.
Here is an example of the code with the group codes in.
$mydata = array(
'email_address' => $email,
'status' => 'pending'
'interests' => array( 'groupid1' => true, 'groupid2' => false));
Does anyone know if it's possible to allocate subscribers to groups when the status is PENDING?
It's possible your code is just throwing an error.
When I take the interests section out, this works perfectly and sends out a confirmation email to the subscriber.
Is it just a syntax error that's breaking the user add process?
$mydata = array(
'email_address' => $email,
'status' => 'pending', // <---- added comma here after 'status' array element declaration.
'interests' => array( 'groupid1' => true, 'groupid2' => false));