Paypal sandbox account deduction not reflecting in account objective c - ios

I am new to paypal integration with objective c.
Created the sanbox (buyer account) which have balance approx 100$
Had download code from : https://github.com/paypal/PayPal-iOS-SDK/tree/master/SampleApp/PayPal-iOS-SDK-Sample-App
ZZAppDelegate.m
[PayPalMobile initializeWithClientIdsForEnvironments:#{ PayPalEnvironmentSandbox : #"XXXXXXX"}];
Execute the project and able to login with buyer account credential.
Click buy button. console show paid successful :
Here is your proof of payment:
{
client =
{
environment = mock;
"paypal_sdk_version" = "2.16.3";
platform = iOS;
"product_name" = "PayPal iOS SDK";
};
response = {
"create_time" = "2017-04-05T05:49:16Z";
id = "PAY-NONETWORKPAYIDEXAMPLE123";
intent = sale;
state = approved;
};
"response_type" = payment;
}
But the problem is : I am not able to see this activity in my sandbox account on browser.
Do we need to add project APPID in sandbox account if yes ? Where do we need to do it?**
APPID :- means apple id (apple bundle identifier) ?
Or there is some different APPID ?
Please help me if there is any steps need to be integrated

If you have added PalPalSDK in application. You have to choose between Sandbox or Production. You have to create AppID for Palpal. You can check there it has sample code also available.
If Payment get successful it has delegate method where we can view with Payment successful.
- (void)sendCompletedPaymentToServer:(PayPalPayment *)completedPayment {
// TODO: Send completedPayment.confirmation to server
NSLog(#"Here is your proof of payment:\n\n%#\n\nSend this to your server for confirmation and fulfillment.", completedPayment.confirmation);
}

here you can get all the data after paypal payment
- (void)payPalPaymentViewController:(PayPalPaymentViewController *)paymentViewController didCompletePayment:(PayPalPayment *)completedPayment
{
NSLog(#"PayPal Payment Success!");
self.resultText = [completedPayment description];
[self sendCompletedPaymentToServer:completedPayment]; // Payment was processed successfully; send to server for verification and fulfillment
[self dismissViewControllerAnimated:YES completion:nil];
}

Related

Flutter ios appstore validateReceipt on non-consumable in-app purchase

I seem to be stuck on this. Trying to validate the receipt (server side) on an in-app purchase on IOS (haven't tried with android, yet.)
I'm using the official in_app_purchase pub package.
This is the setup to initialize the purchase:
Future<bool> initiatePurchase() async {
...
(verify store is available)
..
print ("==> Store available, initiating purchase");
final PurchaseParam purchaseParam =
PurchaseParam(productDetails: _productDetails![0]);
await InAppPurchase.instance.buyNonConsumable(purchaseParam: purchaseParam);
return true;
}
Here's my verify purchase call:
Future<bool> _verifyPurchase(PurchaseDetails purchaseDetails) async {
PurchaseVerifRest purchaseRest = PurchaseVerifRest();
Map<String,dynamic> rsp = await purchaseRest.verifyPurchase(
{
"source": purchaseDetails.verificationData.source,
"vfdata": purchaseDetails.verificationData.serverVerificationData
});
// bundle up the source and verificationData in a map and send to rest
// call
return rsp['status'] == 200;
}
On the server side, the code looks like this (NodeJS/express app)
// (in router.post() call - 'purchaseData' is the map sent in the above code,
// the 'vfdata' member is the 'serverVerificationData'
//. in the 'purchaseDetails' object)
if (purchaseData.source == ('app_store')) {
const IOS_SHARED_SECRET = process.env...;
let postData = {
'receipt-data': purchaseData['vfdata'],
'password': IOS_SHARED_SECRET
};
try {
let verif_rsp = await execPost(postData);
retStatus = verif_rsp.statusCode;
msg = verif_rsp.data;
} catch (e) {
retStatus = e.statusCode;
}
}
What I get back, invariably is
210003 - Receipt could not be authenticated
... even though the purchase seems to go through, whether I validate or not.
Details/questions:
Testing with a sandbox account.
This is for a 'non-consumable' product purchase.
I'm assuming that purchaseDetails.verificationData.serverVerificationData is the payload containing the receipt to send to Apple for verification. Is this not correct? Is there another step I need to do to get the receipt data?
I've read in other posts that the verification step is only for recurring subscriptions and not for other types of products. Is this correct? I don't see anything in Apple's docs to indicate this.
Any thoughts appreciated.

Flutter (IOS) in app purchase receipt data

I use the [in app purchase][1] library to make in-app purchases in the application I developed with Flutter. When a purchase is made, in order to verify in-app purchases for Android on the server side, I am sending the datas as follows, which I need to send by the server.
_verifyPurchase(PurchaseDetails purchase) async {
productID = purchase.productID;
//for android it works nice
if(Platform.isAndroid){
orderId = purchase.billingClientPurchase.orderId;
purchaseToken = purchase.billingClientPurchase.purchaseToken;
purchaseVerify(orderId, purchaseToken, productID);
//but it does not work for iOS and the data required for purchase verification does not go to the server
}else if(Platform.isIOS){
transactionId = purchase.skPaymentTransaction.originalTransaction;
verifData = purchase.verificationData.serverVerificationData;
purchaseVerify(transactionId, verifData, productID);
}
}
purchaseVerify(String orderId, String purchaseToken, String productID) async {
var data = {
'orderId' : orderId,
'purchaseToken' : purchaseToken,
'productId' : productID,
};
res = await Network().authData(data, 'purchaseVerify.php');
}
However, although I try to obtain the data required to verify the in-app purchases for iOS as follows, no data is sent to the server side.
How can I get the data needed to validate in-app purchases for iOS and send it to the server side?

Approved PayPal SDK Payments don't appear on Sandbox Dashboard

The didCompletePayment delegate method confirms the state of my payment is approved:
CurrencyCode: USD
Amount: 1.95
Short Description: avocado
Intent: sale
Processable: Already processed
Display: $1.95
Confirmation: {
client = {
environment = mock;
"paypal_sdk_version" = "2.8.3";
platform = iOS;
"product_name" = "PayPal iOS SDK";
};
response = {
"create_time" = "2015-02-10T16:17:43Z";
id = "PAY-NONETWORKPAYIDEXAMPLE123";
intent = sale;
state = approved;
};
"response_type" = payment;
}
Details: (null)
Shipping Address: (null)
Invoice Number: (null)
Custom: (null)
Soft Descriptor: (null)
BN code: (null)
However, when I go my Dashboard on Developer.PayPal.com, nothing shows up on my transactions page.
Any thoughts on what I could be missing or doing wrong? Is the payment completely verified at this point or do I have to do more logic on the server to verify it? I am already getting the bearer access token before I create the payment and get its info in the delegate callback, but am not sure what I am supposed to do with this token.
Thanks,
Okay, I realized what I was doing wrong.
I was previously using:
PayPalMobile.preconnectWithEnvironment(PayPalEnvironmentNoNetwork)
But needed to be using:
PayPalMobile.preconnectWithEnvironment(PayPalEnvironmentSandbox)
Hope this helps someone else using PayPal SDK for iOS.

Combining Woocommerce with ios in app purchase

I am trying to sync ios in app purchase with woocommerce purchase(web). So when user purchases something in apple store(product lists are same on both side) i would like to view it in woocommerce that item was purchased by that user. FYI, I have a json api plugin that i am using to make request between ios app and site. Any idea how i can do this?
This is how i resolved it
global $woocommerce;
$user = get_user_by('id',$shopId);
if ($user){
wp_set_current_user($shopId,$user->user_login);
wp_set_auth_cookie($shopId);
do_action('wp_login',$user->user_login);
}
if (is_user_logged_in()){
$cart = new WC_Cart();
$checkout = new WC_Checkout();
if ($cart->add_to_cart($productId)){
$orderId = $checkout->create_order(intval($shopId));
}
if (!empty($orderId)){
$order = new WC_Order($orderId);
if (!empty($order)){
$order->update_status("completed","ios app purchase");//I HAD TO SET IT TO COMPLETE SINCE USER BOUGHT IT FROM IOS IN APP PURCHASE
}
//
}
else{
$order = array('fail');
}
}
else{
$order = array();
}
return array($order);

Paypal credit card transaction not working in sandbox mode

I am using paypal ios sdk for payment. I tried to pay with credit card in sandbox mode. I am getting State=pending.It accepts my creditcard details but When I click on charge credit card It procees for that and then I got response from paypal :
{
client = {
environment = sandbox;
"paypal_sdk_version" = "1.3.3";
platform = iOS;
"product_name" = "PayPal iOS SDK";
};
payment = {
amount = "122.00";
"currency_code" = USD;
"short_description" = "Paying to MYAPP";
};
"proof_of_payment" = {
"rest_api" = {
"payment_id" = "PAY-6SB360568W1073911KLY6KAI";
state = pending;
};
};
}
It was working fine in NoNetwork/mockmode. Paypal login is also working in sandbox mode. Does I am missing some thing with credit card?
You most likely have Payment Review enabled for the receiving account. To disable this, click the profile link under the account in your sandbox account list and turn off payment review on the settings tab.

Resources