Changing the pay to account for PayPal mobile transactions - ios

I am using the latest PayPal 2.01 SDK for mobile transactions. I have 2 PayPal business accounts (sales1 and sales2) and based on the transaction I would like to choose which account the transaction is paid to. I have a client ID for each account and want to choose which ID to use for the [PayPalMobile initializeWithClientIdsForEnvironments:#{PayPalEnvironmentProduction: ClientId] call. After I have initialized once, the next initialization is ignored and the client Id is not changed. Can someone tell me how to force the initialization to change the client Id.
if (condition) {
DLog(#"using PP Sales2 account");
[PayPalMobile initializeWithClientIdsForEnvironments:#{PayPalEnvironmentProduction: kPayPalSales2Id,
PayPalEnvironmentSandbox: kPayPalTest2Id}];
} else {
DLog(#"using PP Sales account");
[PayPalMobile initializeWithClientIdsForEnvironments:#{PayPalEnvironmentProduction: kPayPalSalesId,
PayPalEnvironmentSandbox: kPayPalTestId}];

Dave from PayPal here.
The scenario you describe, of switching clientId within a single session, is not one that we have designed the PayPal iOS SDK to handle.
Feel free to post this as an Enhancement request at our github repo.

Related

PayPal parallel adaptive payment verification is not remembering the buyer

I have the following requirements:
The PayPal verification screen remembers the buyer between transactions.
The layout of PayPal verification screen is suitable for mobile devices (responsive layout).
Parallel payments (2 and more receivers).
Apple iOS Safari browser.
Current implementation:
PayPal API: Adaptive Payments.Reference: https://developer.paypal.com/docs/archive/adaptive-payments/integration-guide/APIntro/
Adaptive Payments kind of payment: parallel.
The payment approval type: Explicit approval.
We create the payment on the backend with the call:
POST https://svcs.paypal.com/AdaptivePayments/Pay
Body:
{
'receiverList': {
'receiver': [
{
'primary': false,
'email': 'redacted#example.com',
'amount': '.51'
}
]
},
'memo': 'redacted',
'returnUrl': 'http://oursite.example.com',
'cancelUrl': 'http://oursite.example.com',
'feesPayer': 'EACHRECEIVER',
'actionType': 'PAY',
'currencyCode': 'USD',
'requestEnvelope': {},
'ipnNotificationUrl': 'http://oursite.example.com'
}
After getting the response, we redirect the buyer in Apple Safari (iOS 13.6.1) to:
https://www.paypal.com/webapps/adaptivepayment/flow/pay?expType=mini&paykey=AP-1234567
We get the following pages (one before login, the second after login):
PayPal OneTouch is enabled for the buyer account. Reference: https://www.paypal.com/us/webapps/mpp/one-touch-checkout
The buyer makes the payment in the US with a US-based PayPal account.
The problems:
The layout is not for mobile. It is hard to read and navigate.
PayPal doesn’t remember my previous authentication.
How to fix it?
Adaptive Payments is very old, was deprecated since December of 2017, and is now obsolete.
AP is not mobile optimized, and is not designed to work with One Touch.
You can still test it in Sandbox mode, and legacy live integrations may still work, but no new integrations are supported. You cannot obtain a new Adaptive Payments APP ID. They don't exist anymore.
Basically, you should not use Adaptive Payments for anything.
As for alternate solutions that might work for a "parallel" scenario, perhaps you could implement a PayPal Checkout to a single receiver that has Payouts, and then send Payouts to other receivers. You'll need to contact PayPal to find out if Payouts is permitted for your particular use case and will be activated for your account in live. Here is the information on requesting that approval: https://developer.paypal.com/docs/payouts/integrate/prerequisites/#get-access-to-paypal-payouts

Google Analytics tracking Ecommerce In thankyou page

I’ve got a simple e-commerce site realized in php without using any e-commerce framework.
I’m trying to track purchases amount and their source (organic, social, paid search) with Google analytics using e-commerce tracking. Purchases are done from paypal. I set the thankyou page correctly and users are redirected to this page after the payment. I use Instant Payment Notification for updating the db with the new purchase and send a confirmation email to the customer.
How could I get the client session data to get correctly these data with:
ga('ecommerce:addTransaction', {
'id': '1234', // Transaction ID. Required.
'affiliation': 'Acme Clothing', // Affiliation or store name.
'revenue': '11.99', // Grand Total.
'shipping': '5', // Shipping.
'tax': '1.29' // Tax.
});
And send them with:
ga('ecommerce:send');
The problem is that if I insert the google analytics tracking code in the thankyou page, the page is not “linked” to the session of the customer because paypal redirect there as a new one, I suppose, and I cannot get the purchase and source data.
I also tried to use measurement protocol in IPN page, and that worked fine, but all the traffic in Google Analytics appear as direct, because these informations are sent from the php page on the server and not from the client browser.
I’m looking for the correct approach to these situation.
Thank you
Probably what you are looking for is this.
Google Analytics uses this for its cross-domain tracking, basically it passes the client id from a domain to another through a ?ga=XXXYYYZZZ parameters that links that session to that specific user to bypass the "cross-cookie" situation.
Unfortunately, I do not have experience with IPN but this is probably what you are looking for.
Example:
ga('create', 'UA-XXXXX-Y', 'auto');
ga(function(tracker) {
// Logs the client ID for the current user.
console.log(tracker.get('clientId'));
});
And then you send this clientID in your request and it will be linked by Analytics with the proper information.

Square - How to get ApplicationID using OAuth for Payment Form

Can someone help me to understand how make Payment Form works for merchants?
I am working on ECommerce site where merchants can sell their products. To use Square as payment provider I used OAuth to retrieve access token (which works fine).
To take payment I use Payment Form (to get card nonce). On Payment Form init I need to send ApplicationID & LocationId. I'am able to get last one but not the first one param.
If I try to use my own ApplicationID I get the error on Transactions/Charge
{
"errors":[{
"category":"INVALID_REQUEST_ERROR",
"code":"NOT_FOUND",
"detail":"Card nonce not found in this `sandbox` application environment. Please ensure an application ID belonging to the same environment is used for the SqPaymentForm."
}]
}
This error happens when you use a combination of sandbox application Ids and production application Ids. I'm guessing that you are using your correct application id, and attempting to charge with your sandbox access token.
If you want to take a sandbox payment with the payment form, use your sandbox application id, it should look like sandbox-sq0idp-XXXXXXXXXXXXXXXXXXX
Each merchant must use their own credentials to load locations. You must send the merchant locationId selected and their access_token to do the charge in its account.
Carlos

How do we get transaction fee amount from paypal?

I am using PayPal iOS sdk to accept payment from user in my iOS app. I am using sandbox for testing. The payment is working fine, I am getting successful payment response along with Payment_ID. I am passing that Payment_ID to my server and from there using REST API (Show payment details), I am trying to retrieve all the information related to that payment but it is not consistent response.
Sometimes I am getting transaction_fee while sometimes it does not return in API response.
I see there is another NVP/SOAP method to get details but that requires transaction_id while i am only having Payment_ID.
does anyone have solution on how to get transaction fee from paypal?
I got the solution now!
I was receiving Payment_ID in response from from Paypal iOS SDk after payment successfully done. I am passing that to my server and the server is calling Show payment details REST API to get all payment details
GET /v1/payments/payment/payment_id
In above API response for some cases when transaction state is completed, paypal does not returning transaction_fee_amount. but it returns sale-->id (transactionId).
Using Paypal PHP Library, I used that transactionId and made NVP call for below API,
https://developer.paypal.com/docs/classic/api/merchant/GetTransactionDetails_API_Operation_NVP/
Voila!! In successfull response of that I am getting all the details for that transaction.

PayPal Sandbox - CreateBillingAgreement call returns Internal Error (10001)

I'd appreciate any help with this, I've run around in circles trying all sorts of combinations with the PayPal Api - but I'm hitting a brick wall on this one.
I'm looking to call the CreateBillingAgreement method but each time I do it fails and reports a 10001 'internal error' from paypal in the response.
I have a valid token and I'm using version 84.0. I've successfully called SetupExpressCheckout and DoExpressCheckout, both of which succeed and the payment goes through. I'm setting up a future payment / pre-authorisation on the SetupExpressCheckout and the user agrees to that no problems.
​Do I need to change settings on the merchant in the sandbox? Am I calling things in the wrong order maybe? (SetExpress, GetExpress, DoExpress, CreateBilling)?
​I'm looking to use this billing agreement to allow a reference transaction in the future. I'm having a test account 'pay' using paypal and not forwarding any credit card details, the payment is for a digital service with no delivery (no shipping is set, no addresses or delivery costs are involved). The overall goal is to provide a one-click re-order button, whereby no details need to be entered by the customer.
I'm using the C# api in asp.net 4, or more specifically I've created Service References from the paypal sandbox wsdl and I'm using those in asp.net.
​Any and all help is appreciated - thanks.
​Russell.
You don't need to call CreateBillingAgreement if you're specifying billingtype MerchantInitiatedBilling in your SetExpressCheckout and DoExpressCheckoutPayment API call. CreateBillingAgreement is only necessary if you don't want to call DoExpressCheckoutPayment.
If MerchantInitiatedBilling is set, DoExpressCheckoutPayment will already return a billing agreement ID, which you can use in DoReferenceTransaction.
I don't have access to an example at hand, but will update this post as soon as I've found one for you.

Resources