React Native Paypal Payment Gateway using react-native-paypal-lib - react-native

I have spent more then 6 hours in integrating paypal in React Native. I am using react-native-paypal-lib library.
Code:
RNPaypal.paymentRequest({
clientId: 'MY ID I KNOW',
environment: RNPaypal.ENVIRONMENT.SANDBOX,
intent: RNPaypal.INTENT.SALE,
price: 60,
currency: 'USD',
description: 'Android testing',
acceptCreditCards: true
}).then(response => {
console.log(response)
}).catch(err => {
console.log(err.message)
})
Response:
{response_type: "payment", response: {…}, client: {…}}
client:
environment: "mock"
paypal_sdk_version: "2.15.3"
platform: "Android"
product_name: "PayPal-Android-SDK"
response:
create_time: "2014-07-18T18:46:55Z"
id: "PAY-18X32451H0459092JKO7KFUI"
intent: "sale"
state: "approved"
response_type: "payment"
I am getting the response too. But, I cannot see the transactions in my sandbox account. Also, I am getting the same response id every time.

An approved v1/payment (or v2/order) does not create a transaction. The customer has merely passed through the PayPal.com portion of the process, to give their approval.
After your app is notified of this approval, by e.g. their return from PayPal.com to your app with the details, you must execute the v1/payment (or capture the v2/order), which will create a PayPal transaction. The transaction will have its own new unique ID, which is what you should store for accounting purposes.
(The ID used during the approval process, PAY-##### with v1/payments, or just 17 characters for v2/orders, is only worth keeping around about ~1 month for debug purposes. It has no business/accounting value.)

Related

Facebook js api - "unsupported get request" error

I'm trying to get some (I think allowed) information in my app. I have an access token that has the following info:
App ID: <my app id> : iHOUSEListingPoster - Test 001
Type: User
App-Scoped User ID: <user id> : Joe Webb
Valid: True
Scopes: email, pages_show_list, pages_read_engagement, pages_manage_posts, public_profile
I'm trying this:
FB.api( "/me",
"GET",
{fields: 'name'},
function(get_fb_info_response) {
console.log("Here: ", get_fb_info_response
});
And getting this error:
"Unsupported get request. Object with ID 'me' does not exist, cannot be loaded due to missing permissions, or does not support this operation"
I have tried with both "/me" and "/me/". And while I want name, picture and email, I tried limiting it to just name, and still. What am I missing here?
Try this:
FB.api('/me?fields=name', function(response) {
console.log('me', response);
});
I'm not sure if api function from FB does have this signature you're using.
Edit
After searching at Facebook docs, found that the signature you were using is valid as well. Then, I went to do some tests here. And I was able to reproduce the same error you have mentioned when calling the function like this:
FB.api("/<123>/", "GET", { fields: 'name' }, function(response) {
console.log('response', response);
});
To fix it, you need to remove < and >, for example:
FB.api("/123/", "GET", { fields: 'name' }, function(response) {
console.log('response', response);
});
Calling /me and /me/ endpoint returned no error in my test.
In this screenshot you can see the tests I have run directly at my browser's console.
Ok, I finally figured out what the problem is/was here (sheepish face). We have a couple of Facebook accounts here at the company. One is the container for my app and it's test app, the other is a more general company account. I was logged into the general company account. When I tried my app, it grabbed some random app from that account, which wasn't the app that matched the access token (which I think is possible wrong on Facebook's part), therefore this error was thrown.
Once I logged into the correct Facebook account, all works as expected.

User is not redirected to their respective bank account page while doing transaction on Razorpay?

We are using razorpay as a payment gateway for handling the online payments on our website.
The problem is that some of our customers are not able to complete their transactions as when they select a payment mode (net banking or card payment) they are redirected to a blank window (with URL about:blank)
Ideally, they should be redirected to their respective bank accounts login.
For some customers, everything is working fine and they are able to do their transactions so we do not thing the problem is with integration.
User experience for the user:
User selects online payment
A dialog is popped up handled by Razorpay.
User selects a payment mode.
User clicks on the Pay button
User should be redirected to their bank accounts login.
User logs in and does a transaction
From step 2-5 is handled by razorpay.
I tried contacting their support team but they are not able to figure out the reason for the issue along with any solution.
Please share if anyone has experienced a similar issue and what was the solution for it.
I am considering that there might be some issue on the clients browser(some pop-up blocker or something)
Thank you for your help.
var _this$state2 = _this.state,
shipping = _this$state2.shipping,
billing = _this$state2.billing;
var options = {
key: _env.default.rzpKey,
amount: _this.total * 100,
// 2000 paise = INR 20, amount in paisa
// currency: 'USD',
name: _env.default.siteTitle,
description: 'Your Order',
image: '/static/logo-accent.png',
/* Below Hnadler is called when the transaction is successful */
handler: function handler(response) {
/* Create Order is called when the transaction is successful*/
_this.createOrder(response, _this.state.cod);
},
prefill: {
name: billing.firstName || shipping.firstName,
email: billing.email || shipping.email,
contact: billing.phone || shipping.phone
},
theme: {
color: '#000'
}
};
var rzp = new Razorpay(options); // eslint-disable-line
// Razorpay dialog is opened
rzp.open();

How do you test user flows that involve confirmation by email?

I mean functional or E2E testing. That's all clear with generic flows, but when it comes to transactional emails (signup confirmations, password resets, purchase notifications and others) it's still bringing questions. After some research I came up with a few ideas. One is to leverage Restmail.net API (here examples with Selenium WebDriver and Cypress - http://dsheiko.com/weblog/testing-sign-up-flow-with-activation-by-email). It's free, but API is public. So it's not really suitable for email messages with potentially sensitive information. Another approach to access Gmail inbox via IMAP bridge or Gmail API (here the explanation and code snippets - https://docs.puppetry.app/testing-emails/example-with-imap-bridge). But again, it's rather a workaround.
I know there are guys like Sendgrid, Mailgun, Email Yak, Postmark. I don't want to pay that much. So how do you folks do it? It it a thing to you?
We're doing this using Mailosaur email addresses for our test users. We then use a cypress custom command to query Mailosaur for the expected email. It was super easy to set up.
Here's the main part of that custom command, which is all we had to add to start doing email testing. You can refer to their API docs for what query, mailosaurServer, and MailosaurApiKey should be.
Cypress.Commands.add("getEmailFromMailService", query => {
return cy
.request({
method: "POST",
url: `https://mailosaur.com/api/messages/await?server=${mailosaurServer}`,
body: query,
headers: { "Content-Type": "application/json" },
auth: { user: mailosaurApiKey },
})
.then(response => {
expect(response.status).to.equal(200);
return response.body;
});
});
You could create a post request for the "forgot your password" and then assert on it.
something like:
cy.visit('yoursite')
cy.get('#forgotpassword').click().then(function (xhr) {
cy.server()
cy.request('POST', 'APIforForgotPassword').as('sucessfullemail)
})
cy.get(#sucessfullemail).then(function (xhr) {
expect(xhr.status).to.eq(200)
Cypress.Commands.add('ConfirmUser', () => {
const confirmationToken = null;
cy.request({
url: 'http://localhost:3000/api/confirmation_token?email=test_user#cypress.com',
followRedirect: false
})
.then((resp) => {
confirmationToken = resp.token
})
cy.visit('/en/confirmation?confirmation_token=token')
})
Create the API that requires the email as a parameter and returns the confirmation-token. call the API from cypress commands as ajax-request and get the response token

Stripe integration with 3D Secure

I have an Express app that I had successfully tested with tokenisation of payments. As I'm in the UK and will be accepting mainly UK cards, I believe I need to implement 3D Secure handling. I'm really struggling to understand the official documentation - examples are few and far between in my opinion. From the following: https://stripe.com/docs/sources/three-d-secure
I have got Sources working instead of Card payments using tokens. This is step 1. Step 2 requires that I determine if the card supports 3D Secure. I have been doing this client side but am not sure how to handle this subsequently - I have been attempting to send the user for a card payment if 3D Secure is not required. BUT if it is required, do i need to create another Source? And do I do this server or client side? I also cannot get the return_url field to do anything - 3D Secure cards simply fail.
Are there any examples out there that would help me? I am finding the official docs simply tell you roughly what to do with not much in the way of 'how' to do things.
I should add I am using v3 with Elements, NOT Checkout.
Thanks for any help.
edit: the below server-side doesn't seem to do anything:
stripe.sources.create({
amount: 6500,
currency: 'gbp',
type: "three_d_secure",
three_d_secure: {
card: stripeSource,
},
redirect: {
return_url: "http://example.com"
}
})
The documentation states "To allow your customer to verify their identity using 3D Secure, redirect them to the URL provided within theredirect[url] attribute of the Source object."
My source object doesn't contain this field?
edit: This is what I have now. The redirect works, but as soon as I authorize the payment, the card declines:
stripe.customers.create({
email: cust_email,
source: stripeSource
}).then(function(customer){
return stripe.charges.create({
amount: fee,
description: "Client Ref: " + clientref,
currency: "gbp",
customer: customer.id,
metadata: {
'allocation:': allocate
},
receipt_email: cust_email,
source: request.query.source,
})
}
).catch(err => {
console.log(err)
})
stripe.sources.create({
amount: fee,
currency: 'gbp',
type: "three_d_secure",
three_d_secure: {
card: stripeSource,
},
redirect: {
return_url: "http://localhost:8000/charge"
}
}).then(function(test) {
response.redirect(test.redirect.url)
})

RingCentral: After successfully making a new subscription, there is no webhook posted while the RingOut call is in progress

Yesterday, I found a problem that after successfully making a new subscription, there is no webhook posted to the specified URL while the RingOut call is in progress.
So far, when my app subscribes for the events (mentioned below), I see that the whole process go through just fine and my webhook endpoint always gets something back from RingCentral. However, after that, there is ZERO postback to that webhook endpoint so far.
The webhook endpoint is always accessible and operational without issue.
At the moment, I believe that there is no postback from RingCentral but I am not so sure about that.
I would like some guidance how to investigate this issue.
Steps to reproduce the problem:
Make a new subscription or ignore if there is an active webhook subscription for the following events:
/restapi/v1.0/account/~/extension/~/presence?detailedTelephonyState=true&sipData=true
/restapi/v1.0/account/~/extension/~/presence/line/presence?detailedTelephonyState=true
Make a RingOut call.
I discovered the same issue as I built out this sample app showing how Webhooks with RingCentral can operate: https://github.com/bdeanindy/ringcentral-webhook-basics
> ringcentral-webhook-basics#0.1.0 start /Users/benjamin.dean/MyApps/ringcentral-webhook-basics
> node index.js
PORT: 3000
Server is listening on port: 3000
LOGIN SUCCESS DATA: { access_token: 'HIDDEN',
token_type: 'bearer',
expires_in: 3600,
refresh_token: 'HIDDEN',
refresh_token_expires_in: 604800,
scope: 'ReadMessages Faxes ReadPresence ReadAccounts EditExtensions RingOut SMS InternalMessages ReadCallLog ReadCallRecording Accounts',
owner_id: 'HIDDEN',
endpoint_id: 'HIDDEN' }
BODY:
Subscription Response: { uri: 'https://platform.devtest.ringcentral.com/restapi/v1.0/subscription/HIDDEN',
id: 'HIDDEN',
creationTime: '2016-09-15T22:48:45.877Z',
status: 'Active',
eventFilters:
[ '/restapi/v1.0/account/133128004/extension/134694004/presence?detailedTelephonyState=true',
'/restapi/v1.0/account/133128004/extension/133128004/presence?detailedTelephonyState=true',
'/restapi/v1.0/account/133128004/extension/664573005/presence?detailedTelephonyState=true',
'/restapi/v1.0/account/133128004/extension/133165004/presence?detailedTelephonyState=true',
'/restapi/v1.0/account/133128004/extension/138323004/presence?detailedTelephonyState=true' ],
expirationTime: '2016-09-22T22:48:45.877Z',
expiresIn: 604799,
deliveryMode:
{ transportType: 'WebHook',
encryption: false,
address: 'http://fbe654d0.ngrok.io/webhooks?auth_token=HIDDEN' } }
Just made a call from soft phone to my mobile device (no events are arriving).
Now I am going to hangup the call and then I am going to change the availability status of the user to see if that generates events...
BODY: {"uuid":"88474bfa-061e-4184-9e39-3ca78e51e1be","event":"/restapi/v1.0/account/133128004/extension","timestamp":"2016-09-15T22:50:34.418Z","subscriptionId":"ad355889-74cc-4db1-9fd0-fc20f442c261","body":{"extensions":[{"extensionId":"133128004","eventType":"Update"}]}}
BODY: {"uuid":"bc236a49-e01b-4c3f-bb75-872745381a3b","event":"/restapi/v1.0/account/133128004/extension","timestamp":"2016-09-15T22:50:34.418Z","subscriptionId":"26ba88c0-0554-4ff7-8dfb-e1f597306176","body":{"extensions":[{"extensionId":"133128004","eventType":"Update"}]}}
BODY: {"uuid":"4efc4740-3b26-43a4-8c74-e984a778c364","event":"/restapi/v1.0/account/133128004/extension","timestamp":"2016-09-15T22:50:34.418Z","subscriptionId":"b2d76ced-b860-4fb9-af1d-aeb55cf2bf0f","body":{"extensions":[{"extensionId":"133128004","eventType":"Update"}]}}
BODY: {"uuid":"b3d53990-26ae-4241-8eac-0acfe210c6cb","event":"/restapi/v1.0/account/133128004/extension","timestamp":"2016-09-15T22:50:34.418Z","subscriptionId":"f22cec6d-3f0e-4a10-aa6b-e3a726fe8e61","body":{"extensions":[{"extensionId":"133128004","eventType":"Update"}]}}
BODY: {"uuid":"4a3aebe7-8fd7-411b-8cf6-6809be3491a1","event":"/restapi/v1.0/account/133128004/extension","timestamp":"2016-09-15T22:50:34.418Z","subscriptionId":"9dc0fbd3-b5dc-4b09-9dd1-db61098b6195","body":{"extensions":[{"extensionId":"133128004","eventType":"Update"}]}}
BODY: {"uuid":"54fe63e4-6cec-4da7-b91b-02066f2218d7","event":"/restapi/v1.0/account/133128004/extension","timestamp":"2016-09-15T22:50:37.431Z","subscriptionId":"ad355889-74cc-4db1-9fd0-fc20f442c261","body":{"extensions":[{"extensionId":"133128004","eventType":"Update"}]}}
BODY: {"uuid":"3abf1018-816b-48cd-a8b5-eb7c484f25bc","event":"/restapi/v1.0/account/133128004/extension","timestamp":"2016-09-15T22:50:37.431Z","subscriptionId":"26ba88c0-0554-4ff7-8dfb-e1f597306176","body":{"extensions":[{"extensionId":"133128004","eventType":"Update"}]}}
BODY: {"uuid":"70fba7c1-e820-408c-897f-387d23aad789","event":"/restapi/v1.0/account/133128004/extension","timestamp":"2016-09-15T22:50:37.431Z","subscriptionId":"f22cec6d-3f0e-4a10-aa6b-e3a726fe8e61","body":{"extensions":[{"extensionId":"133128004","eventType":"Update"}]}}
BODY: {"uuid":"20a4207e-9574-43ad-8246-afb2bb728853","event":"/restapi/v1.0/account/133128004/extension","timestamp":"2016-09-15T22:50:37.431Z","subscriptionId":"b2d76ced-b860-4fb9-af1d-aeb55cf2bf0f","body":{"extensions":[{"extensionId":"133128004","eventType":"Update"}]}}
BODY: {"uuid":"aa3d2e9f-dde5-4259-b14d-f105056784d1","event":"/restapi/v1.0/account/133128004/extension","timestamp":"2016-09-15T22:50:37.431Z","subscriptionId":"9dc0fbd3-b5dc-4b09-9dd1-db61098b6195","body":{"extensions":[{"extensionId":"133128004","eventType":"Update"}]}}
So we are not receiving any telephony events for VOIP, but we are receiving presence events for the extension.
Now, let's try sending an SMS and see if we receive any events.
Nope, no events for SMS either.
I found that no telephony related events were being POSTed to my webhook endpoint as expected, but the extension presence events (updates and modifications to availability) were generating events.
I have contacted our engineering team to investigate this issue and to help get it resolved.
Thank you for reporting this Janielle. I will update this post when it has been fixed.