Transportersio / omnipay-square

MIT License
4 stars 21 forks source link

Invalid argument supplied for foreach() WebPaymentRequest.php on line 40 #18

Open aneeshrp opened 1 year ago

aneeshrp commented 1 year ago

Warning: Invalid argument supplied for foreach() in /Users/aneeshramakrishnapillai/Documents/Development/www/sandbox/omnipay/vendor/transportersio/omnipay-square/src/Message/WebPaymentRequest.php on line 40 "omnipay/omnipay": "^3.2", "transportersio/omnipay-square": "^2.1"

require 'vendor/autoload.php';

use Omnipay\Omnipay;

$gateway = Omnipay::create('Square'); $gateway->setAccessToken('__id_'); $gateway->setLocationId('id__'); $gateway->setTestMode(true); // Set test mode to true for sandbox environment

// Charge a credit card $response = $gateway->purchase([ 'amount' => '10.00', 'currency' => 'USD', 'card' => [ 'number' => '4808499845665488', 'expiryMonth' => '12', 'expiryYear' => '2024', 'cvv' => '385', ], ])->send();

// Process response if ($response->isSuccessful()) {

// Payment was successful
print_r($response);

} elseif ($response->isRedirect()) {

// Redirect to offsite payment gateway
$response->redirect();

} else {

// Payment failed
echo $response->getMessage();

}