-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: adds purchase products api response
- Loading branch information
1 parent
e538fc5
commit 0ed6109
Showing
9 changed files
with
103 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
android/src/main/java/com/chargebee/android/models/PurchaseResult.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package com.chargebee.android.models | ||
|
||
import com.chargebee.android.network.ReceiptDetail | ||
import java.io.Serializable | ||
|
||
data class PurchaseResult ( | ||
val subscriptionId: String?, | ||
val planId: String?, | ||
val status: Boolean | ||
) : Serializable { | ||
constructor(receiptDetail: ReceiptDetail, status: Boolean) : this(receiptDetail.subscription_id, receiptDetail.plan_id, status) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
// | ||
// CBPurchase.swift | ||
// ChargebeeReactNative | ||
// | ||
// Created by cb-haripriyan on 17/02/23. | ||
// | ||
|
||
import Foundation | ||
|
||
struct CBPurchaseResult: Codable { | ||
|
||
let subscriptionId: String? | ||
let planId: String? | ||
let status: Bool | ||
|
||
enum CodingKeys: String, CodingKey { | ||
case subscriptionId = "subscription_id" | ||
case planId = "plan_id" | ||
case status | ||
} | ||
} | ||
|
||
extension CBPurchaseResult { | ||
init(fromTuple: (status:Bool, subscriptionId:String?, planId:String?)) { | ||
self.subscriptionId = fromTuple.subscriptionId | ||
self.status = fromTuple.status | ||
self.planId = fromTuple.planId | ||
} | ||
} | ||
|
||
extension CBPurchaseResult { | ||
var asDictionary: [String:Any] { | ||
var dictionary: [String: Any] = [:] | ||
dictionary["subscription_id"] = self.subscriptionId | ||
dictionary["plan_id"] = self.planId | ||
dictionary["status"] = self.status | ||
return dictionary | ||
} | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,12 +1,12 @@ | ||
import type { TurboModule } from 'react-native'; | ||
import { TurboModuleRegistry } from 'react-native'; | ||
import type { Product } from '.'; | ||
import type { Product, Purchase } from '.'; | ||
|
||
export interface Spec extends TurboModule { | ||
configure(site: string, publishableApiKey: string, sdkKey: string): void; | ||
retrieveProductIdentifiers(queryParams: Object): Promise<Array<string>>; | ||
retrieveProducts(productIds: Array<string>): Promise<Product>; | ||
purchaseProduct(productId: string, customerId: string): Promise<string>; | ||
purchaseProduct(productId: string, customerId: string): Promise<Purchase>; | ||
} | ||
|
||
export default TurboModuleRegistry.getEnforcing<Spec>('ChargebeeReactNative'); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters