PayPal API - cancel_url gives only token? - api

Is it possible to get the Payer ID?
The return_url provides Payer ID, amount etc .. while the cancel_url gives only token.

There was no payment, so no payer, so no payer ID. There was no transaction, so no transaction ID. No money was paid, so no amount.

If you are using the Paypal-PHP-SDK is not possible at this moment, the unique solution for now is save the token when you create the payment. In DEV-MASTER branch they have added a new method called "getToken()" to Payment class, so you will get the token easily when you create a payment. You can track the issue using the next URL Paypal-PHP-SDK issue 832
$payment->create($apiContext);
$token = $payment->getToken();
PS: Remember, this method "getToken()" is only available in DEV-MASTER for now.

Related

Setting BTC Pay Server invoice expiration time to never?

This is a follow up question to this post but my question is more programming related so I'm hoping this is the right place to post it.
I too am trying to use BTC Pay Server as a wallet. Thera are two problems:
As described in the article, you have to specify an amount when creating an invoice.
It has a security feature that basically results in you not being able to re-use deposit addresses.
The workaround for problem 1 is to set the invoice amount to 0.000001 BTC. So low that the client will always overpay. That works for me to.
But my problem is that address must not expire ever. I checked the code:
Here you can see the Invoice object.
Here you can see the code in use.
It looks like I might be able to use this:
public function setExpirationTime($expirationTime)
{
if (is_a($expirationTime, 'DateTime')) {
$this->expirationTime = $expirationTime;
} else if (is_numeric($expirationTime)) {
$expirationDateTime = new \DateTime('', new \DateTimeZone("UTC"));
$expirationDateTime->setTimestamp($expirationTime);
$this->expirationTime = $expirationDateTime;
}
return $this;
}
And set the expiration time to the year 3000. So my questions are:
Will BTC Pay server ditch my address if I attempt to use this to make it never expire?
Will I still receive the funds if a user sends to an expired address/
Or is there perhaps a better way to get BTC Pay server to act as a wallet as I want it to?
Thanks!
Will BTC Pay server ditch my address if I attempt to use this to
make it never expire?
Actually, you may encounter the year 2038 problem if the type for expirationTime is DateTime. If that really is the case, it will be set a negative value when you try to pass a value larger than 2038. It is unclear what will happen next.
If the system the code is running on is 64bit, then the Y2038 problem does not apply.
Will I still receive the funds if a user sends
to an expired address
https://docs.btcpayserver.org/FAQ/FAQ-Stores/#payment-invalid-if-transactions-fails-to-confirm-minutes-after-invoice-expiration
If the customer pays the invoice, but it fails to get the defined
number of confirmations within the set period, it is marked as
"invalid." The merchant can then decide whether to accept the invoice
afterward manually or decline it and require additional payment from
the customer. This is an additional protection mechanism against the
volatility
So not exactly - some work is required on your part to accept it, if it expires.
Or is there perhaps a better way to get BTC
Pay server to act as a wallet as I want it to?
Instead of setting it to the year 3000, why don't you just set the invoice a year ahead at a time ?

Oauth2 Scope for invoices in Xero API?

What is the correct scope to generate invoices using the Xero API?
The docs say I should direct users to the following URL:
https://login.xero.com/identity/connect/authorize?
response_type=code&
client_id=YOURCLIENTID&
redirect_uri=YOURREDIRECTURI&
scope=openid profile email accounting.transactions&
state=123
And says:
scope permissions to request (links to here)
But I can't see anything that clearly states "Invoicing" or "Create invoice" unless its one of the following:
Accounting API
accounting.transactions
accounting.transactions.read
accounting.reports.read
accounting.journals.read
accounting.settings
accounting.settings.read
accounting.contacts
accounting.contacts.read
accounting.attachments
accounting.attachments.read
What values do I need to pass as the scope parameter?
Invoice interactions are included in the set of business transactions covered by the accounting.transactions scope (and accounting.transactions.read for read-only actions).

Can I set variable monthly payment amounts through PayPal REST API's billing plan/agreement? On existing agreements?

I entered this as an issue on the PayPal-PHP-SDK github but it's rather time sensitive at this point.
Our goal is a subscription service that monthly charges users a value they select for each content update during that month. A $1 subscriber would pay $8 if there were 8 updates, for example.
Our implementation so far (which is already live with a number of subscribers) is using the PayPal-PHP-SDK / REST API to create a Billing Plan for each subscriber with a payment definition set to an amount calculated to be the maximum potential monthly charge. I then expected to be able to use Agreement->setBalance() to lower the value to the actual intended charge and then Agreement->billBalance() to process the payment.
Unfortunately due to time pressures we launched without verifying this was a viable implementation, and I've discovered that those functions are only for unpaid/delinquent balances. The start_date on our plans is April 1, and we'll have had 4 content releases but we're set to charge our subscribers for the maximum possible 9 updates.
I've tried a variety of Agreement->update() and Plan->update() calls to change the monthly value, along the lines of:
$Patch = new PayPal\Api\Patch();
$Patch->setOp("replace")
->setPath("/payment_definitions/0/amount/value")
->setValue($patch_value);
$PatchRequest = new PayPal\Api\PatchRequest();
$PatchRequest->addPatch($Patch);
$Plan = PayPal\Api\Plan::get($plan_id, $apiContext);
$Plan->update($PatchRequest, $apiContext);
which returns an exception with "validation_error: Invalid Path provided". Attempts to json encode the data path, up to and including the entire Plan object with $Patch->setPath("/") instead give an exception with "MALFORMED_REQUEST - Incoming JSON request does not map to API request". I suspect most values cannot be updated on an executed agreement or activated plan.
However, I see through the merchant account's website that the monthly value can be manually updated, so I hold out hope that I'm simply going about my API requests the wrong way.
I've also tried creating a Payment object with Transaction->setPurchaseUnitReferenceId($AgreementId) since I'd read something about reference transactions being a potential solution, but I'm getting the same malformed request error:
$Item = new PayPal\Api\Item();
$Item->setCategory('DIGITAL')
->setPrice($pledge_value)
->setDescription($update_name);
$ItemList = new PayPal\Api\ItemList();
$ItemList->addItem($Item);
$Amount = new PayPal\Api\Amount();
$Amount->setCurrency('USD')
->setTotal($pledge_value);
$Transaction = new PayPal\Api\Transaction();
$Transaction->setPurchaseUnitReferenceId($AgreementId)
->setDescription($update_name)
->setAmount($Amount)
->setItemList($ItemList)
->setNotifyUrl($notify_url);
$Payer = new PayPal\Api\Payer();
$Payer->setPaymentMethod('paypal');
$RedirectUrls = new PayPal\Api\RedirectUrls();
$RedirectUrls->setReturnUrl($return_url)
->setCancelUrl($cancel_url);
$Payment = new PayPal\Api\Payment();
$Payment->setIntent('sale')
->setPayer($Payer)
->setRedirectUrls($RedirectUrls)
->addTransaction($Transaction);
$Payment->create($apiContext);
So is there a way to fix our current implementation and plans/agreements? Failing that, is there a REST API solution that I should have used / can try to migrate to? I'd like to avoid Classic API if possible.

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.

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>