Checkout API get email of buyer on redirect - square

So using the square checkout api, after the user uses the square checkout, I get a transaction id and checkout id, but it seems theres no way to get the information the buyer entered at checkout. How can I get the email and name of said buyer?
Tried getting the info through the checkout id but it seems its not possible
// pull out the transaction ID returned by Square Checkout
$returnedTransactionId = $_GET["transactionId"];
// Create a new API object to verify the transaction
$transactionClient = new \SquareConnect\Api\TransactionsApi($defaultApiClient);
// Ping the Transactions API endpoint for transaction details
try {
// Get transaction details for this order from the Transactions API endpoint
$apiResponse = $transactionClient->retrieveTransaction(
$locationId,
$returnedTransactionId
);
} catch (Exception $e) {
echo "The SquareConnect\Configuration object threw an exception while " .
"calling TransactionsApi->retrieveTransaction: ",
$e->getMessage(), PHP_EOL;
exit;
}

Once you retrieve the transaction like you're already doing, the response will have a field called tenders, and in this array field you'll find a field called customer_id. Using this customer_id, you can call RetrieveCustomer and get the customer's information, including their name and email.

Related

How to send Lumens to an uninitialised stellar address pragmatically

I am new to stellar so please bear with my question if it sounds too basic.
So, using the stellar laboratory, I created two accounts lets name 1 and 2. I funded the 1st account with test-net coins using friend-bot and left the 2nd account empty. Now as I understand that an account to be active on stellar network, it should have a minimum balance of about 1XLM. So using the transaction builder, I tried to perform a Payment Operation by trying to transfer 2XLM to the 2nd account. However I recieved the following response :
{
"type": "https://stellar.org/horizon-errors/transaction_failed",
"title": "Transaction Failed",
"status": 400,
"detail": "The transaction failed when submitted to the stellar network. The `extras.result_codes` field on this response contains further details. Descriptions of each code can be found at: https://www.stellar.org/developers/learn/concepts/list-of-operations.html",
"extras": {
"envelope_xdr": "AAAAAKNyr+6/r2REKzMV3sOL4jztg1HSdqlQhmthUU41BjPdAAAAZAAEmkQAAAADAAAAAAAAAAAAAAABAAAAAAAAAAEAAAAAmWhqbEZTUrZWFtvR1HU7VUW0pp3BwN4E9h4iQwvMr9kAAAAAAAAAAAExLQAAAAAAAAAAATUGM90AAABAHvtdpnjhq3usHFphQ/4naDHbKVhu+QqD8UFSavo/qlGo7Yiz/dLI3lQ0fmfa37uvwXWsYAn8mObDkrTjofc3Aw==",
"result_codes": {
"transaction": "tx_failed",
"operations": [
"op_no_destination"
]
},
"result_xdr": "AAAAAAAAAGT/////AAAAAQAAAAAAAAAB////+wAAAAA="
}
}
So can someone tell me which operation I need to use to send XLM to an un-initialised address so I can activate it, not by using friendbot.
First, you need to execute Create Account from the Transaction Builder.
Only then you can transfer funds to this address.
I think it's because the Stellar laboratory is not set up for this exact use case. It is more for getting a general feel of the basics. In order to create an account this way using an SDK and communicating with horizon you would have to both create the account and fund it in a single transaction, and therefore you would have to input the source account's secret key.
In the Stellar lab's account creation tab there is no way to input a source address its secret key (or at least I didn't see one).
So in your example, your first account is created and funded by the testbot. However, when you create the second account and try to send a payment to it from the first account, the reason it fails is because the second account is not yet a valid account as it has not been funded yet. Kind of a chicken and egg problem.
The good news is you can definitely do this using the SDK, but I haven't found a way to do it using the lab.
This from stellar.org about building transactions:
https://www.stellar.org/developers/js-stellar-base/reference/building-transactions.html
TransactionBuilder
The TransactionBuilder class is used to construct
new transactions. TransactionBuilder is given an account that is used
as transaction’s “source account”. The transaction will use the
current sequence number of the given Account object as its sequence
number and increments the given account’s sequence number when build()
is called on the TransactionBuilder.
Operations can be added to the transaction calling
addOperation(operation) for each operation you wish to add to the
transaction. See operation.js for a list of possible operations you
can add. addOperation(operation) returns the current
TransactionBuilder object so you can chain multiple calls.
After adding the desired operations, call the build() method on the
TransactionBuilder. This will return a fully constructed Transaction.
The returned transaction will contain the sequence number of the
source account. This transaction is unsigned. You must sign it before
it will be accepted by the Stellar network.
# This is the relevant code
StellarSdk.Network.useTestNetwork();
// StellarBase.Network.usePublicNetwork(); if this transaction is for the public network
// Create an Account object from an address and sequence number.
var account=new StellarBase.Account("GD6WU64OEP5C4LRBH6NK3MHYIA2ADN6K6II6EXPNVUR3ERBXT4AN4ACD","2319149195853854");
var transaction = new StellarBase.TransactionBuilder(account, {
fee: StellarBase.BASE_FEE
})
// add a payment operation to the transaction
.addOperation(StellarBase.Operation.payment({
destination: "GASOCNHNNLYFNMDJYQ3XFMI7BYHIOCFW3GJEOWRPEGK2TDPGTG2E5EDW",
asset: StellarBase.Asset.native(),
amount: "100.50" // 100.50 XLM
}))
// add a set options operation to the transaction
.addOperation(StellarBase.Operation.setOptions({
signer: {
ed25519PublicKey: secondAccountAddress,
weight: 1
}
}))
// mark this transaction as valid only for the next 30 seconds
.setTimeout(30)
.build();
# Note that it is adding different operations to a single transaction.

Get Buyer Email from Omnipay Paypal Express

I integrated the Omnipay PayPal express.
After the completePurchase() I need the PayPal buyer email adress.
I can access the Transaction ID with $data['PAYMENTINFO_0_TRANSACTIONID'] and also the Payer ID through $_GET['PayerID'].
Any ideas how to get the buyers email?
After completePurchase(), you need to fetch the checkout datas:
$response = $gateway->fetchCheckout($parameters)->send();
$data = $response->getData();
// you can check the full received data
print "<pre>";
var_dump($data);
And in this array, you've got a $data["EMAIL"] variable, wich stores the payer's e-mail address.
Regards!
P.s.: For more information and a TL;DR disquisition, check this.

Getting Transaction ID from Authorize.Net CIM API

I am creating a CIM API for authorize.net. I have it all working perfectly, but I need the transaction id to be returned to me when a transaction is created.
Right now, this what I have being returned when I complete a transaction:
if ($cim->isSuccessful())
{
$approval_code = $cim->getAuthCode();
}
// Print the results of the request
echo '<strong>Request Response Summary:</strong> ' .
$cim->getResponseSummary() . '';
echo '<strong>Approval code:</strong> ' . $approval_code;
Then this is the output I get: Request Response Summary: Response code: I00001 Message: Successful.Approval code: NXD8X7
No transaction ID is returned. I want to know how I can go about getting this. My goal is to write this to my database, but I need some way to get the transaction id. Thank you very much.
If you are using AuthorizeNet SDK you can get all response fields as an object with calling $response->getTransactionResponse function like following.
$request = new AuthorizeNetCIM();
$response = $request->createCustomerProfileTransaction('AuthCapture', $transaction);
$transactionResponse = $response->getTransactionResponse();
$transactionResponse->transaction_id

Paymill API: How do I update a subscription's credit card?

I can create subscriptions, but I can't figure out how to update a subscription so that it uses a new credit card.
This is what I've tried: (assuming there is already an existing client, payment and subscription)
create token in ui
create a payment object in server
update client like this:
paymill.clients.update(clientId, { payment: payment.id }, callback);
I get this error:
Error: Identifier,payment
Exception: Api_Exception_InvalidParameter
Which calls do I need to make to achieve this?
Paymill has updated the api and you can now make this request which can be used to update cc details on a subscription.
First create a payment and then update the subscription with the new payment id.
curl -X PUT https://api.paymill.com/v2/subscriptions/<SubscriptionId> -u <ApiKey>: -d payment=<PaymentId>

Send an email via MailChimp

I think problem is around $api->listSubscribers()
include('../libs/mailchimp/MCAPI.class.php');
$options = array('list_id' => '$list_id', 'subject' => 'Prova', 'from_name' => 'name', 'from_email' => 'info#example.com');
$content = array('html' => '<p>Testo di prova</p>');
$api = new MCAPI($apikey);
$campaignId = $api->campaignCreate('trans', $options, $content);
$api->listSubscribe($options['list_id']);
$api->campaignSendNow($campaignId);
if ($api->errorCode){
echo "Unable to Create New Campaign!";
echo "\n\tCode=".$api->errorCode;
echo "\n\tMsg=".$api->errorMessage."\n";
} else {
echo "New Campaign ID:".$campaignId ."\n";
}
Why does'nt it send an email?
You have a several issues here:
The first one is that you are not doing error checking after each API call. If you take the error checking code from the bottom and stick it after the listSubscribe() call, you'll immediately get an error because you aren't passing any sort of subscriber data (at the very least you need the email address). The docs for listSubscribe are here
Once you do that - unless you've thoroughly read and considered the options in the listSubscribe docs - your second issue is going to be that you are running listSubscribe with the double_optin parameter set to true (the default), which means they won't be subscribed until clicking a link in the confirmation email.
Next, that code is just going to get you in trouble, and probably quickly. If you are going to use psuedo-transcational campaigns it is imperrative that you only create ONE psuedo-trans campaign per type of email and then send that campaign over and over. That's how they are intended to work. Not doing that is going to cause you to fill up your account with a whole bunch of trash campaigns at which point there's no point in using a psuedo-trans campaign since that's the same as creating/sending a regular campaign to a single user over and over.
Do you get any errors?
It seems you are not including the api key, it should look like:
$api = new MCAPI($apikey);
Instead of:
$api = new MCAPI('apikey');
You get the API Key from your api dashboard: http://admin.mailchimp.com/account/api